Devang Patel
654e47f366
Ignore dbg intrinsic while folding unconditional branch.
...
llvm-svn: 64242
2009-02-10 22:14:17 +00:00
Devang Patel
02f58e1e8d
Revert rev. 63876. It is causing llvm-gcc bootstrap failure.
...
llvm-svn: 63888
2009-02-05 21:46:41 +00:00
Devang Patel
5922e26d1a
Ignore dbg intrinsics while propagating conditional expression info.
...
llvm-svn: 63876
2009-02-05 19:15:39 +00:00
Devang Patel
086b212277
Ignore dbg intrinsics while folding switch instruction.
...
llvm-svn: 63802
2009-02-05 00:30:42 +00:00
Devang Patel
916fdce16d
Ignore dbg intrinsics.
...
llvm-svn: 63781
2009-02-04 21:39:48 +00:00
Devang Patel
fd9f635103
While folding vallue comparison terminators ignore dbg intrinsics.
...
llvm-svn: 63700
2009-02-04 01:06:11 +00:00
Devang Patel
f10e287c65
Ignore dbg intrinsics while hoisting common code in the two blocks up into the branch block.
...
llvm-svn: 63687
2009-02-04 00:03:08 +00:00
Devang Patel
2032cadd0f
Do not let dbg intrinsic block folding of two entry phi node.
...
llvm-svn: 63671
2009-02-03 22:12:02 +00:00
Chris Lattner
c59945b4bd
another fix for PR3354
...
llvm-svn: 62561
2009-01-20 01:15:41 +00:00
Bill Wendling
caf1d22243
Doxygen-ify comments.
...
llvm-svn: 62546
2009-01-19 23:43:56 +00:00
Chris Lattner
ea9f1d3c47
Fix a problem exposed by PR3354: simplifycfg was making a potentially
...
trapping instruction be executed unconditionally.
llvm-svn: 62541
2009-01-19 23:03:13 +00:00
Bill Wendling
534d2e0bae
Temporarily revert r62487. It's causing this error during a release bootstrap of
...
llvm-gcc. Most likely, it's miscompiling one of the "gen*" programs:
/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/xgcc -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.obj/./prev-gcc/ -B/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm-gcc.install/i386-apple-darwin9.6.0/bin/ -c -g -O2 -mdynamic-no-pic -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -mdynamic-no-pic -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/build -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include -DENABLE_LLVM -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/../llvm.src/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o build/gencondmd.o build/gencondmd.c
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: excess elements in struct initializer
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: warning: (near initialization for 'insn_conditions[4]')
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected '}' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:926: error: expected ',' or ';' before ')' token
../../llvm-gcc.src/gcc/config/i386/mmx.md:927: error: expected identifier or '(' before ',' token
../../llvm-gcc.src/gcc/config/i386/sse.md:3458: error: expected identifier or '(' before ',' token
...
llvm-svn: 62506
2009-01-19 08:46:20 +00:00
Chris Lattner
f2bb4ea39c
Fix PR3016, a bug which can occur do to an invalid assumption:
...
we assumed a CFG structure that would be valid when all code in
the function is reachable, but not all code is necessarily
reachable. Do a simple, but horrible, CFG walk to check for this
case.
llvm-svn: 62487
2009-01-19 02:46:28 +00:00
Chris Lattner
e381d7026f
reduce indentation by using 'continue', no functionality change.
...
llvm-svn: 62477
2009-01-19 02:07:32 +00:00
Chris Lattner
54f0c61d71
Fix some problems in SpeculativelyExecuteBB. Basically,
...
because of dead code, a phi could use the speculated instruction
that was not in "BB2". Make this check explicit and tighten up
some other corners. This fixes PR3292. No testcase becauase this
depends entirely on visitation order of blocks and requires a
sequence of 8 passes to repro.
llvm-svn: 62476
2009-01-19 00:36:37 +00:00
Chris Lattner
e1c01e4e2b
Make this a bit more explicit about which cases need the
...
check. No functionality change.
llvm-svn: 62474
2009-01-18 23:22:07 +00:00
Eli Friedman
cb61afb546
Add a helper to remove a branch and DCE the condition, and use it
...
consistently for deleting branches. In addition to being slightly
more readable, this makes SimplifyCFG a bit better
about cleaning up after itself when it makes conditions unused.
llvm-svn: 61100
2008-12-16 20:54:32 +00:00
Chris Lattner
f50d7f76c6
fix a bug I introduced in simplifycfg handling single entry phi
...
nodes. FoldSingleEntryPHINodes deletes the PHI, so there is no
need to delete it afterward.
llvm-svn: 60653
2008-12-07 07:22:45 +00:00
Chris Lattner
dc3f6f2c12
Factor some code into a new FoldSingleEntryPHINodes method.
...
llvm-svn: 60501
2008-12-03 19:44:02 +00:00
Chris Lattner
7eb270ed03
Rename DeleteBlockIfDead to DeleteDeadBlock and make it
...
unconditionally delete the block. All likely clients will
do the checking anyway.
llvm-svn: 60464
2008-12-03 06:40:52 +00:00
Chris Lattner
bcc904a67c
Factor some code out of SimplifyCFG, forming a new
...
DeleteBlockIfDead method.
llvm-svn: 60463
2008-12-03 06:37:44 +00:00
Chris Lattner
8e84c129ce
delete ErasePossiblyDeadInstructionTree, replacing uses of it with
...
RecursivelyDeleteTriviallyDeadInstructions.
llvm-svn: 60196
2008-11-27 23:25:44 +00:00
Chris Lattner
d6204bed3d
simplify this code a bit.
...
llvm-svn: 60164
2008-11-27 07:54:38 +00:00
Chris Lattner
0934c0f35b
Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
...
I don't really see this as being needed, but there is little harm from doing
it.
llvm-svn: 58385
2008-10-29 17:46:26 +00:00
Devang Patel
f963403b58
Nick Lewycky's patch.
...
While hosting instruction check PHI node.
llvm-svn: 57025
2008-10-03 18:57:37 +00:00
Devang Patel
4c758ea3e0
Large mechanical patch.
...
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g
This sets the stage
- to implement function notes as function attributes and
- to distinguish between function attributes and return value attributes.
This requires corresponding changes in llvm-gcc and clang.
llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Devang Patel
76b22c1420
Try to place hoisted instructions befoe icmp instruction.
...
llvm-svn: 56315
2008-09-18 22:50:42 +00:00
Devang Patel
7f9671ba37
Do not hoist instruction above branch condition. The instruction may use branch condition.
...
llvm-svn: 56286
2008-09-17 18:21:49 +00:00
Dan Gohman
8de6d22392
Use empty() instead of begin() == end().
...
llvm-svn: 54780
2008-08-14 18:13:49 +00:00
Dan Gohman
fa1211f69b
Enable first-class aggregates support.
...
Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.
The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.
llvm-svn: 53941
2008-07-23 00:34:11 +00:00
Owen Anderson
9858691f25
Reapply r53735. My last patch fixed the failures Dan observed.
...
llvm-svn: 53761
2008-07-18 17:49:43 +00:00
Dan Gohman
29c3adaae0
Revert r53735. It broke SPEC 464.h264ref.
...
llvm-svn: 53757
2008-07-18 16:44:49 +00:00
Owen Anderson
fd7102037d
Use MergeBlockIntoPredecessor to simplify some code.
...
llvm-svn: 53735
2008-07-17 20:00:46 +00:00
Chris Lattner
80b03a1b49
Fix mishandling of the infinite loop case when merging two blocks. This
...
fixes PR2540.
llvm-svn: 53533
2008-07-13 22:23:11 +00:00
Chris Lattner
834ab4ec1b
more refactoring. Use early exits instead of really complex logic.
...
No functionality change.
llvm-svn: 53532
2008-07-13 22:04:41 +00:00
Chris Lattner
5eed37224a
improve comments.
...
llvm-svn: 53531
2008-07-13 21:55:46 +00:00
Chris Lattner
9aada1d755
factor another large hunk of code out into its own function.
...
No functionality change.
llvm-svn: 53530
2008-07-13 21:53:26 +00:00
Chris Lattner
55eaae1e0c
Final bit of simplification for FoldBranchToCommonDest.
...
llvm-svn: 53528
2008-07-13 21:20:19 +00:00
Chris Lattner
1b317ea48a
simplify logic a bit
...
llvm-svn: 53527
2008-07-13 21:15:11 +00:00
Chris Lattner
2e25b8f444
Refactor some code out into its own helper function, getting rid of crazy multiline
...
conditionals and commenting the code better.
No functionality change.
llvm-svn: 53526
2008-07-13 21:12:01 +00:00
Evan Cheng
5fd28b54c7
- Use O(1) check of basic block size limit.
...
- Avoid speculatively execute vector ops.
llvm-svn: 52703
2008-06-25 07:50:12 +00:00
Evan Cheng
89553cc42e
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.
...
llvm-svn: 52244
2008-06-12 21:15:59 +00:00
Evan Cheng
933c743042
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.
llvm-svn: 52224
2008-06-11 19:18:20 +00:00
Gabor Greif
945f2f7fed
op_iterator-ify loops
...
llvm-svn: 52191
2008-06-10 22:03:26 +00:00
Evan Cheng
89200c9177
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
llvm-svn: 52073
2008-06-07 08:52:29 +00:00
Dan Gohman
f96e1371e8
Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to
...
use it instead of duplicating its functionality.
llvm-svn: 51499
2008-05-23 21:05:58 +00:00
Matthijs Kooijman
aef2b8198b
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.
llvm-svn: 51478
2008-05-23 09:09:41 +00:00
Gabor Greif
e1f6e4b21d
API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
...
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Gabor Greif
697e94cc22
Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
...
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Chris Lattner
8be72700b8
Fix PR2256, yet another miscompilation in simplifycfg of i
...
multiple return values.
Bill, please pull this into Tak.
llvm-svn: 50332
2008-04-28 00:19:07 +00:00
Nick Lewycky
4d43d3c72c
Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
...
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.
llvm-svn: 50265
2008-04-25 16:53:59 +00:00
Chris Lattner
86bbf338e5
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.
llvm-svn: 50199
2008-04-24 00:01:19 +00:00
Gabor Greif
e9ecc68d8f
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.
llvm-svn: 49277
2008-04-06 20:25:17 +00:00
Dan Gohman
20af5a0fe7
Check to see if a two-entry PHI block can be simplified
...
before trying to merge the block into its predecessors.
This allows two-entry-phi-return.ll to be simplified
into a single basic block.
llvm-svn: 48252
2008-03-11 21:53:06 +00:00
Nick Lewycky
fb2c1a999a
Turn unwind_to into "unwinds to".
...
llvm-svn: 48123
2008-03-10 02:20:00 +00:00
Nick Lewycky
42445be0df
Firstly, having a BranchInst isn't exclusive with having an unwind_to.
...
Secondly, we have to check whether the branch is actually pointing to the block
with the unwind in it. We could have gotten here because of the unwind_to alone.
llvm-svn: 48099
2008-03-09 07:50:37 +00:00
Nick Lewycky
f3d637fa14
A BB that unwind_to an "unwind" inst is that same as one that doesn't unwind_to
...
at all.
llvm-svn: 48096
2008-03-09 07:36:38 +00:00
Nick Lewycky
5ce9b521d7
Update the inliner and simplifycfg to handle unwind_to.
...
llvm-svn: 48086
2008-03-09 05:10:13 +00:00
Anton Korobeynikov
1bfd121321
Make Transforms to be 4.3 warnings-clean
...
llvm-svn: 47371
2008-02-20 11:26:25 +00:00
Chris Lattner
6b39cb907b
switch simplifycfg from using vectors for most things to smallvectors,
...
this speeds it up 2.3% on eon.
llvm-svn: 47261
2008-02-18 07:42:56 +00:00
Chris Lattner
f391883670
don't hoist FP additions into unconditional adds + selects. This
...
could theoretically introduce a trap, but is also a performance issue.
This speeds up ptrdist/ks by 8%.
llvm-svn: 45533
2008-01-03 07:25:26 +00:00
Chris Lattner
f3ebc3f3d2
Remove attribution from file headers, per discussion on llvmdev.
...
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
Devang Patel
7a2c66b11e
If succ has succ itself as one of the predecessors then do
...
not merge current bb and succ even if bb's terminator is
unconditional branch to succ.
llvm-svn: 45305
2007-12-22 01:32:53 +00:00
Duncan Sands
ad0ea2d430
Fix PR1146: parameter attributes are longer part of
...
the function type, instead they belong to functions
and function calls. This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully
a bitcode guru (who might that be? :) ) will fix it.
llvm-svn: 44359
2007-11-27 13:23:08 +00:00
David Greene
17a5dfe6f7
New CallInst interface to address GLIBCXX_DEBUG errors caused by
...
indexing an empty std::vector.
Updates to all clients.
llvm-svn: 40660
2007-08-01 03:43:44 +00:00
Dan Gohman
30978078bf
Minor comment cleanups.
...
llvm-svn: 37321
2007-05-24 14:36:04 +00:00
Chris Lattner
77a3edcb92
remove use of Instruction::getNext
...
llvm-svn: 36199
2007-04-17 17:47:54 +00:00
Chris Lattner
b7b75145f1
reduce use of std::set
...
llvm-svn: 35576
2007-04-02 01:44:59 +00:00
Dan Gohman
dcb291faa4
Change uses of Function::front to Function::getEntryBlock for readability.
...
llvm-svn: 35265
2007-03-22 16:38:57 +00:00
Reid Spencer
bb38d79ad6
Make sorting of ConstantInt be APInt clean through use of ult function.
...
llvm-svn: 34853
2007-03-02 23:01:14 +00:00
Chris Lattner
a06a8fd2d7
Eliminate use of ctors that take vectors.
...
llvm-svn: 34219
2007-02-13 02:10:56 +00:00
Chris Lattner
8dd4cae4f8
simplify code by using Value::takeName
...
llvm-svn: 34177
2007-02-11 01:37:51 +00:00
Chris Lattner
024f4ab383
Adjust #includes to match movement of constant folding code from transformutils to libanalysis.
...
llvm-svn: 33680
2007-01-30 23:46:24 +00:00
Reid Spencer
a94d394ad2
For PR1043:
...
This is the final patch for this PR. It implements some minor cleanup
in the use of IntegerType, to wit:
1. Type::getIntegerTypeMask -> IntegerType::getBitMask
2. Type::Int*Ty changed to IntegerType* from Type*
3. ConstantInt::getType() returns IntegerType* now, not Type*
This also fixes PR1120.
Patch by Sheng Zhou.
llvm-svn: 33370
2007-01-19 21:13:56 +00:00
Chris Lattner
03c4953cdd
rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
...
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.
This makes naming much more consistent. For example, there are now no longer any
instances of IntegerType that are not considered isInteger! :)
llvm-svn: 33225
2007-01-15 02:27:26 +00:00
Chris Lattner
1942249c5b
Eliminate calls to isInteger, generalizing code and tightening checks as needed.
...
llvm-svn: 33218
2007-01-15 01:55:30 +00:00
Reid Spencer
cddc9dfe97
Implement review feedback for the ConstantBool->ConstantInt merge. Chris
...
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.
llvm-svn: 33110
2007-01-12 04:24:46 +00:00
Reid Spencer
542964f55b
Rename BoolTy as Int1Ty. Patch by Sheng Zhou.
...
llvm-svn: 33076
2007-01-11 18:21:29 +00:00
Zhou Sheng
75b871fb1e
For PR1043:
...
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.
llvm-svn: 33073
2007-01-11 12:24:14 +00:00
Reid Spencer
266e42b312
For PR950:
...
This patch removes the SetCC instructions and replaces them with the ICmp
and FCmp instructions. The SetCondInst instruction has been removed and
been replaced with ICmpInst and FCmpInst.
llvm-svn: 32751
2006-12-23 06:05:41 +00:00
Reid Spencer
6c38f0bb07
For PR950:
...
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.
llvm-svn: 31931
2006-11-27 01:05:10 +00:00
Bill Wendling
4ae401074c
Remove #include <iostream> and use llvm_* streams instead.
...
llvm-svn: 31925
2006-11-26 10:17:54 +00:00
Chris Lattner
95adf8f1da
Do not convert massive blocks on phi nodes into select statements. Instead
...
only do these transformations if there are a small number of phi's.
This speeds up Ptrdist/ks from 2.35s to 2.19s on my mac pro.
llvm-svn: 31853
2006-11-18 19:19:36 +00:00
Reid Spencer
fdff938a7e
For PR950:
...
This patch converts the old SHR instruction into two instructions,
AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not
dependent on the sign of their operands.
llvm-svn: 31542
2006-11-08 06:47:33 +00:00
Reid Spencer
de46e48420
For PR786:
...
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.
llvm-svn: 31380
2006-11-02 20:25:50 +00:00
Chris Lattner
fc519cd2d1
Fix SimplifyCFG/2006-10-29-InvokeCrash.ll, a crash compiling QT.
...
llvm-svn: 31284
2006-10-29 21:21:20 +00:00
Reid Spencer
e0fc4dfc22
For PR950:
...
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.
llvm-svn: 31063
2006-10-20 07:07:24 +00:00
Chris Lattner
b8b11599dd
Fix SimplifyCFG/2006-10-19-UncondDiv.ll by disabling a bad xform.
...
llvm-svn: 31061
2006-10-20 00:42:07 +00:00
Chris Lattner
c9009d917d
Fix PR867 (and maybe 868) and testcsae:
...
Transforms/SimplifyCFG/2006-08-03-Crash.ll
llvm-svn: 29515
2006-08-03 21:40:24 +00:00
Chris Lattner
b5c9d7a0af
Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.ll
...
llvm-svn: 28758
2006-06-12 20:18:01 +00:00
Chris Lattner
35515557c7
remove some dead code identified by coverity
...
llvm-svn: 28289
2006-05-14 18:45:44 +00:00
Chris Lattner
3237da073e
remove dead variables
...
llvm-svn: 28286
2006-05-14 18:33:57 +00:00
Chris Lattner
d95665188b
Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll
...
llvm-svn: 26275
2006-02-18 00:33:17 +00:00
Chris Lattner
469640e506
Add explicit #includes of <iostream>
...
llvm-svn: 25509
2006-01-22 22:53:01 +00:00
Chris Lattner
2820b8c855
Fix SimplifyCFG/2005-12-03-IncorrectPHIFold.ll
...
llvm-svn: 24581
2005-12-03 18:25:58 +00:00
Chris Lattner
4c3b2b536c
Clean up the code a bit. Use isInstructionTriviallyDead to be more aggressive
...
and more correct than use_empty(). This fixes PR635 and
SimplifyCFG/2005-10-02-InvokeSimplify.ll
llvm-svn: 23616
2005-10-03 23:43:43 +00:00
Chris Lattner
499e33646e
remove some debugging code
...
llvm-svn: 23411
2005-09-23 18:49:09 +00:00
Chris Lattner
c59a371d45
Fold two consequtive branches that share a common destination between them.
...
This implements SimplifyCFG/branch-fold.ll, and is useful on ?:/min/max heavy
code
llvm-svn: 23410
2005-09-23 18:47:20 +00:00
Chris Lattner
3a978bf66d
simplify some logic further
...
llvm-svn: 23408
2005-09-23 07:23:18 +00:00
Chris Lattner
cc14ebc17b
pull a bunch of logic out of SimplifyCFG into a helper fn
...
llvm-svn: 23407
2005-09-23 06:39:30 +00:00
Chris Lattner
6c70106053
Start threading across blocks with code in them, so long as the code does
...
not define a value that is used outside of it's block. This catches many
more simplifications, e.g. 854 in 176.gcc, 137 in vpr, etc.
This implements branch-phi-thread.ll:test3.ll
llvm-svn: 23397
2005-09-20 01:48:40 +00:00
Chris Lattner
f0bd8d0107
Implement merging of blocks with the same condition if the block has multiple
...
predecessors. This implements branch-phi-thread.ll::test1
llvm-svn: 23395
2005-09-20 00:43:16 +00:00
Chris Lattner
049cb4482f
Reject a case we don't handle yet
...
llvm-svn: 23393
2005-09-19 23:57:04 +00:00
Chris Lattner
a160924d57
remove debugging code :-/
...
llvm-svn: 23392
2005-09-19 23:50:15 +00:00
Chris Lattner
748f903046
Implement SimplifyCFG/branch-phi-thread.ll, the most trivial case of threading
...
control across branches with determined outcomes. More generality to follow.
This triggers a couple thousand times in specint.
llvm-svn: 23391
2005-09-19 23:49:37 +00:00
Chris Lattner
d683bdd0f8
Fix Transforms/SimplifyCFG/2005-08-03-PHIFactorCrash.ll, a problem that
...
occurred while bugpointing another testcase
llvm-svn: 22621
2005-08-03 17:59:45 +00:00
Chris Lattner
2dbf1960ff
Finally, add the required constraint checks to fix Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll
...
the right way
llvm-svn: 22615
2005-08-03 00:59:12 +00:00
Chris Lattner
908036942c
Simplify some code, add the correct pred checks
...
llvm-svn: 22613
2005-08-03 00:38:27 +00:00
Chris Lattner
982b75c061
Refactor code out of PropagatePredecessorsForPHIs, turning it into a pure function with no side-effects
...
llvm-svn: 22612
2005-08-03 00:29:26 +00:00
Chris Lattner
1f047fd513
use splice instead of remove/insert to avoid some symtab operations
...
llvm-svn: 22611
2005-08-03 00:23:42 +00:00
Chris Lattner
76dc204488
move two functions up in the file, use SafeToMergeTerminators to eliminate
...
some duplicated code
llvm-svn: 22610
2005-08-03 00:19:45 +00:00
Chris Lattner
733d6704ce
Rip some code out of the main SimplifyCFG function into a subfunction and
...
call it from the only place it is live. No functionality changes.
llvm-svn: 22609
2005-08-03 00:11:16 +00:00
Chris Lattner
ac594de8dc
Disable this patch:
...
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050801/027345.html
This breaks real programs and only fixes an obscure regression testcase. A
real fix is in development.
llvm-svn: 22606
2005-08-02 23:31:38 +00:00
Chris Lattner
eee90f7eb4
Change a place to use an arbitrary value instead of null, when possible
...
llvm-svn: 22605
2005-08-02 23:29:23 +00:00
Chris Lattner
4fd3e16cbd
This code was very close, but not quite right. It did not take into
...
consideration the case where a reference in an unreachable block could
occur. This fixes Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll,
something I ran into while bugpoint'ing another pass.
llvm-svn: 22584
2005-08-02 03:24:05 +00:00
Chris Lattner
5e735294bf
Don't crash on: X = phi (X, X).
...
This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll
llvm-svn: 22232
2005-06-17 01:45:53 +00:00
Chris Lattner
19f9f32a5c
Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
...
llvm-svn: 22158
2005-05-20 22:19:54 +00:00
Chris Lattner
bcefcf8552
Make sure to preserve the calling convention when changing an invoke into
...
a call. This fixes Prolangs-C++/deriv2, kimwitu++, and Misc-C++/bigfib
on X86 with -enable-x86-fastcc.
llvm-svn: 22023
2005-05-14 12:21:56 +00:00
Misha Brukman
b1c9317bb4
Remove trailing whitespace
...
llvm-svn: 21427
2005-04-21 23:48:37 +00:00
Chris Lattner
b38b443b15
Teach simplifycfg that setcc is cheap and non-trapping, so that it can
...
convert this:
%tmp.1 = seteq int %i, 0 ; <bool> [#uses=1]
br bool %tmp.1, label %shortcirc_done, label %shortcirc_next
shortcirc_next: ; preds = %entry
%tmp.4 = seteq int %j, 0 ; <bool> [#uses=1]
br label %shortcirc_done
shortcirc_done: ; preds = %shortcirc_next, %entry
%shortcirc_val = phi bool [ %tmp.4, %shortcirc_next ], [ true, %entry ] ; <bool> [#uses=1]
to this:
%tmp.1 = seteq int %i, 0 ; <bool> [#uses=1]
%tmp.4 = seteq int %j, 0 ; <bool> [#uses=1]
%shortcirc_val = select bool %tmp.1, bool true, bool %tmp.4 ; <bool> [#uses=1]
... which is later simplified by instcombine into an or.
llvm-svn: 21388
2005-04-21 05:31:13 +00:00
Chris Lattner
95f16a3ac4
Get rid of this for_each loop
...
llvm-svn: 21253
2005-04-12 18:51:33 +00:00
Chris Lattner
0ce80cd542
Fix spelling, patch contributed by Gabor Greif!
...
llvm-svn: 20343
2005-02-27 06:18:25 +00:00
Chris Lattner
cc6d75fddf
remove extraneous cast
...
llvm-svn: 20334
2005-02-26 18:33:28 +00:00
Chris Lattner
1cca959e5d
Implement Transforms/SimplifyCFG/switch_thread.ll
...
This does a simple form of "jump threading", which eliminates CFG edges that
are provably dead. This triggers 90 times in the external tests, and
eliminating CFG edges is always always a good thing! :)
llvm-svn: 20300
2005-02-24 06:17:52 +00:00
Chris Lattner
a35dfcedd3
switchinst ctor now takes a hint for the number of cases that it will have.
...
llvm-svn: 19898
2005-01-29 00:38:26 +00:00
Chris Lattner
3215bb6049
Implement SimplifyCFG/DeadSetCC.ll
...
SimplifyCFG is one of those passes that we use for final cleanup: it should
not rely on other passes to clean up its garbage. This fixes the "why are
trivially dead setcc's in the output of gccas" problem.
llvm-svn: 19212
2005-01-01 16:02:12 +00:00
Chris Lattner
4fc998da2e
Fix Regression/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll,
...
and the failure on make_dparser last night.
llvm-svn: 18766
2004-12-10 17:42:31 +00:00
Chris Lattner
019445715e
Squelch warning
...
llvm-svn: 18381
2004-11-30 07:47:34 +00:00
Chris Lattner
fd8cbc257e
Alkis noticed that this variable is dead. Thanks!
...
llvm-svn: 18369
2004-11-30 04:01:44 +00:00
Chris Lattner
389cfac0d1
If we have something like this:
...
if (x) {
code
...
} else {
code
...
}
Turn it into:
code
if (x) {
...
} else {
...
}
This reduces code size and in some common cases allows us to completely
eliminate the conditional. This turns several if/then/else blocks in loops
into straightline code in 179.art, turning the loops into single basic blocks
(good for modsched even!).
Maybe now brg will leave me alone ;-)
llvm-svn: 18366
2004-11-30 00:29:14 +00:00
Chris Lattner
93d1e39f3e
Do not compute the predecessor list for a block unless we need it.
...
This speeds up simplifycfg on this program, from 44.87s to 0.29s (with
a profiled build):
#define CL0(a) case a: goto c;
#define CL1(a) CL0(a##0) CL0(a##1) CL0(a##2) CL0(a##3) CL0(a##4) CL0(a##5) \
CL0(a##6) CL0(a##7) CL0(a##8) CL0(a##9)
#define CL2(a) CL1(a##0) CL1(a##1) CL1(a##2) CL1(a##3) CL1(a##4) CL1(a##5) \
CL1(a##6) CL1(a##7) CL1(a##8) CL1(a##9)
#define CL3(a) CL2(a##0) CL2(a##1) CL2(a##2) CL2(a##3) CL2(a##4) CL2(a##5) \
CL2(a##6) CL2(a##7) CL2(a##8) CL2(a##9)
#define CL4(a) CL3(a##0) CL3(a##1) CL3(a##2) CL3(a##3) CL3(a##4) CL3(a##5) \
CL3(a##6) CL3(a##7) CL3(a##8) CL3(a##9)
void f();
void a() {
int b;
c: switch (b) {
CL4(1)
}
}
This testcase is contrived to expose N^2 behavior, but this patch should speedup
simplifycfg on any programs that use large switch statements. This testcase
comes from GCC PR17895.
llvm-svn: 17389
2004-11-01 06:53:58 +00:00
Reid Spencer
fad217c847
Eliminate compilation warning on uninitialized variable.
...
llvm-svn: 17163
2004-10-22 16:10:39 +00:00
Chris Lattner
5edb2f32d0
Simplify code by deleting instructions that preceed unreachable instructions.
...
Simplify code by simplifying terminators that branch to blocks that start
with an unreachable instruction.
llvm-svn: 17116
2004-10-18 04:07:22 +00:00
Chris Lattner
45c35b1d1f
When converting phi nodes into select instructions, we shouldn't promote PHI
...
nodes unless we KNOW that we are able to promote all of them.
This fixes: test/Regression/Transforms/SimplifyCFG/PhiNoEliminate.ll
llvm-svn: 16973
2004-10-14 05:13:36 +00:00
Chris Lattner
879ce7894c
Do not insert trivially dead select instructions, which allows us to
...
potentially fold more in one pass.
llvm-svn: 16583
2004-09-29 05:43:32 +00:00
Reid Spencer
6614946443
Convert code to compile with vc7.1.
...
Patch contributed by Paolo Invernizzi. Thanks Paolo!
llvm-svn: 16368
2004-09-15 17:06:42 +00:00
Alkis Evlogimenos
a5c04ee50f
Fixes to make LLVM compile with vc7.1.
...
Patch contributed by Paolo Invernizzi!
llvm-svn: 16152
2004-09-03 18:19:51 +00:00
Reid Spencer
7c16caa336
Changes For Bug 352
...
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.
llvm-svn: 16137
2004-09-01 22:55:40 +00:00
Brian Gaeke
902dcf0729
These files don't need to include <iostream> since they include "Support/Debug.h".
...
llvm-svn: 15089
2004-07-21 20:50:33 +00:00
Chris Lattner
5823ac1c21
Implement SimplifyCFG/BrUnwind.ll
...
llvm-svn: 15022
2004-07-20 01:17:38 +00:00
Reid Spencer
ef784f01dd
bug 122:
...
- Minimize redundant isa<GlobalValue> usage
llvm-svn: 14948
2004-07-18 00:32:14 +00:00
Chris Lattner
32c518e526
Progress on PR341
...
llvm-svn: 14840
2004-07-15 02:06:12 +00:00
Reid Spencer
eb04d9bcb4
Add #include <iostream> since Value.h does not #include it any more.
...
llvm-svn: 14622
2004-07-04 12:19:56 +00:00
Chris Lattner
f12c4a3d37
*FINALLY* Fix a really nasty nondeterministic bug that has been haunting us
...
since May 1st. In this code, the pred iterator was being invalidated sometimes
causing the wrong entries to be added to PHI nodes.
The fix for this is to defererence and safe the *PI value before we hack on
branch instructions, which changes use/def chains, which SOMETIMES invalidates
the iterator.
llvm-svn: 14278
2004-06-21 07:19:01 +00:00
Chris Lattner
9734fd0980
Add some DEBUG output to the simplifycfg routines
...
Fix another non-deterministic behavior, this one should actually speed up the
code though as it was doing silly things.
llvm-svn: 14258
2004-06-20 01:13:18 +00:00
Chris Lattner
b2b151d297
Do not sort by the address of LLVM ConstantInt* objects. This produces
...
nondeterministic results that depend on where these objects land in memory.
Instead, sort by the value of the constant, which is stable.
Before this patch, the -simplifycfg pass run from two different compilers
could cause different code to be generated, though it was semantically the
same:
@@ -12258,8 +12258,8 @@
%s_addr.1 = phi sbyte* [ %s, %entry ], [ %inc.0, %no_exit ] ; <sbyte*> [#uses=5]
%tmp.1 = load sbyte* %s_addr.1 ; <sbyte> [#uses=1]
switch sbyte %tmp.1, label %no_exit [
- sbyte 0, label %loopexit
sbyte 46, label %loopexit
+ sbyte 0, label %loopexit
]
We need to stomp all of this stuff out.
llvm-svn: 14243
2004-06-19 07:02:14 +00:00
Chris Lattner
be6f06818c
Do not clone arbitrary condition instructions.
...
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner
51a6dbcb65
Do not infinitely "unroll" single BB loops.
...
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner
1e94ed606e
Dont' merge terminators that are needed to select PHI node values.
...
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner
2e93c4275e
Implement SimplifyCFG/branch-cond-merge.ll
...
Turning "if (A < B && B < C)" into "if (A < B & B < C)"
llvm-svn: 13311
2004-05-01 23:35:43 +00:00
Chris Lattner
4cbd160b45
Fix my missing parens
...
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner
88da6f7b52
Implement SimplifyCFG/branch-cond-prop.ll
...
llvm-svn: 13306
2004-05-01 22:36:37 +00:00
Chris Lattner
0aa565647c
Fold code like:
...
if (C)
V1 |= V2;
into:
Vx = V1 | V2;
V1 = select C, V1, Vx
when the expression can be evaluated unconditionally and is *cheap* to
execute. This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:
int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;
void mux(void) {
output =
(in0 ? 0x00000001 : 0) | (in1 ? 0x00000002 : 0) |
(in2 ? 0x00000004 : 0) | (in3 ? 0x00000008 : 0) |
(in4 ? 0x00000010 : 0) | (in5 ? 0x00000020 : 0) |
(in6 ? 0x00000040 : 0) | (in7 ? 0x00000080 : 0) |
(in8 ? 0x00000100 : 0) | (in9 ? 0x00000200 : 0) |
(in10 ? 0x00000400 : 0) | (in11 ? 0x00000800 : 0) |
(in12 ? 0x00001000 : 0) | (in13 ? 0x00002000 : 0) |
(in14 ? 0x00004000 : 0) | (in15 ? 0x00008000 : 0) ;
}
llvm-svn: 12798
2004-04-09 22:50:22 +00:00
Chris Lattner
eed034bcd3
Fix the obvious bug in my previous checkin
...
llvm-svn: 12618
2004-04-02 18:15:10 +00:00
Chris Lattner
9f0db32625
Implement Transforms/SimplifyCFG/return-merge.ll
...
This actually causes us to turn code like:
return C ? A : B;
into a select instruction.
llvm-svn: 12617
2004-04-02 18:13:43 +00:00
Chris Lattner
81bdcb90ce
Now that all the code generators support the select instruction, and the instcombine
...
pass can eliminate many nasty cases of them, start generating them in the optimizers
llvm-svn: 12545
2004-03-30 19:44:05 +00:00
Chris Lattner
a078f47b39
Fix compilation of mesa, which I broke earlier today
...
llvm-svn: 12465
2004-03-17 02:02:47 +00:00
Chris Lattner
a64923ad26
Do not copy gigantic switch instructions
...
llvm-svn: 12441
2004-03-16 19:45:22 +00:00
Chris Lattner
d3e6ae263c
Implement switch->br and br->switch folding by ripping out the switch->switch
...
and br->br code and generalizing it. This allows us to compile code like this:
int test(Instruction *I) {
if (isa<CastInst>(I))
return foo(7);
else if (isa<BranchInst>(I))
return foo(123);
else if (isa<UnwindInst>(I))
return foo(1241);
else if (isa<SetCondInst>(I))
return foo(1);
else if (isa<VAArgInst>(I))
return foo(42);
return foo(-1);
}
into:
int %_Z4testPN4llvm11InstructionE("struct.llvm::Instruction"* %I) {
entry:
%tmp.1.i.i.i.i.i.i.i = getelementptr "struct.llvm::Instruction"* %I, long 0, ubyte 4 ; <uint*> [#uses=1]
%tmp.2.i.i.i.i.i.i.i = load uint* %tmp.1.i.i.i.i.i.i.i ; <uint> [#uses=2]
%tmp.2.i.i.i.i.i.i = seteq uint %tmp.2.i.i.i.i.i.i.i, 27 ; <bool> [#uses=0]
switch uint %tmp.2.i.i.i.i.i.i.i, label %endif.0 [
uint 27, label %then.0
uint 2, label %then.1
uint 5, label %then.2
uint 14, label %then.3
uint 15, label %then.3
uint 16, label %then.3
uint 17, label %then.3
uint 18, label %then.3
uint 19, label %then.3
uint 32, label %then.4
]
...
As well as handling the cases in 176.gcc and many other programs more effectively.
llvm-svn: 11964
2004-02-28 21:28:10 +00:00
Chris Lattner
21e941fbfd
turn things like:
...
if (X == 0 || X == 2)
...where the comparisons and branches are in different blocks... into a switch
instruction. This comes up a lot in various programs, and works well with
the switch/switch merging code I checked earlier. For example, this testcase:
int switchtest(int C) {
return C == 0 ? f(123) :
C == 1 ? f(3123) :
C == 4 ? f(312) :
C == 5 ? f(1234): f(444);
}
is converted into this:
switch int %C, label %cond_false.3 [
int 0, label %cond_true.0
int 1, label %cond_true.1
int 4, label %cond_true.2
int 5, label %cond_true.3
]
instead of a whole bunch of conditional branches.
Admittedly the code is ugly, and incomplete. To be complete, we need to add
br -> switch merging and switch -> br merging. For example, this testcase:
struct foo { int Q, R, Z; };
#define A (X->Q+X->R * 123)
int test(struct foo *X) {
return A == 123 ? X1() :
A == 12321 ? X2():
(A == 111 || A == 222) ? X3() :
A == 875 ? X4() : X5();
}
Gets compiled to this:
switch int %tmp.7, label %cond_false.2 [
int 123, label %cond_true.0
int 12321, label %cond_true.1
int 111, label %cond_true.2
int 222, label %cond_true.2
]
...
cond_false.2: ; preds = %entry
%tmp.52 = seteq int %tmp.7, 875 ; <bool> [#uses=1]
br bool %tmp.52, label %cond_true.3, label %cond_false.3
where the branch could be folded into the switch.
This kind of thing occurs *ALL OF THE TIME*, especially in programs like
176.gcc, which is a horrible mess of code. It contains stuff like *shudder*:
#define SWITCH_TAKES_ARG(CHAR) \
( (CHAR) == 'D' \
|| (CHAR) == 'U' \
|| (CHAR) == 'o' \
|| (CHAR) == 'e' \
|| (CHAR) == 'u' \
|| (CHAR) == 'I' \
|| (CHAR) == 'm' \
|| (CHAR) == 'L' \
|| (CHAR) == 'A' \
|| (CHAR) == 'h' \
|| (CHAR) == 'z')
and
#define CONST_OK_FOR_LETTER_P(VALUE, C) \
((C) == 'I' ? SMALL_INTVAL (VALUE) \
: (C) == 'J' ? SMALL_INTVAL (-(VALUE)) \
: (C) == 'K' ? (unsigned)(VALUE) < 32 \
: (C) == 'L' ? ((VALUE) & 0xffff) == 0 \
: (C) == 'M' ? integer_ok_for_set (VALUE) \
: (C) == 'N' ? (VALUE) < 0 \
: (C) == 'O' ? (VALUE) == 0 \
: (C) == 'P' ? (VALUE) >= 0 \
: 0)
and
#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
{ \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
copy_to_mode_reg (SImode, XEXP (X, 1))); \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
copy_to_mode_reg (SImode, XEXP (X, 0))); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
force_operand (XEXP (X, 0), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
force_operand (XEXP (X, 1), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
XEXP (X, 1)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
force_operand (XEXP (X, 1), NULL_RTX)); \
if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
|| GET_CODE (X) == LABEL_REF) \
(X) = legitimize_address (flag_pic, X, 0, 0); \
if (memory_address_p (MODE, X)) \
goto WIN; }
and others. These macros get used multiple times of course. These are such
lovely candidates for macros, aren't they? :)
This code also nicely handles LLVM constructs that look like this:
if (isa<CastInst>(I))
...
else if (isa<BranchInst>(I))
...
else if (isa<SetCondInst>(I))
...
else if (isa<UnwindInst>(I))
...
else if (isa<VAArgInst>(I))
...
where the isa can obviously be a dyn_cast as well. Switch instructions are a
good thing.
llvm-svn: 11870
2004-02-26 07:13:46 +00:00
Chris Lattner
90ea78edba
If a block is made dead, make sure to promptly remove it.
...
llvm-svn: 11799
2004-02-24 16:09:21 +00:00
Chris Lattner
a2ab489135
Implement SimplifyCFG/switch_switch_fold.ll
...
This case occurs many times in various benchmarks, especially when combined
with the previous patch. This allows it to get stuff like:
if (X == 4 || X == 3)
if (X == 5 || X == 8)
and
switch (X) {
case 4: case 5: case 6:
if (X == 4 || X == 5)
llvm-svn: 11797
2004-02-24 07:23:58 +00:00
Chris Lattner
3cd98f054a
Rearrange code a bit
...
llvm-svn: 11793
2004-02-24 05:54:22 +00:00
Chris Lattner
6f4b45acf5
Implement: test/Regression/Transforms/SimplifyCFG/switch_create.ll
...
This turns code like this:
if (X == 4 | X == 7)
and
if (X != 4 & X != 7)
into switch instructions.
llvm-svn: 11792
2004-02-24 05:38:11 +00:00
Chris Lattner
e42732e75f
Implement test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll,
...
see the testcase for the reasoning.
llvm-svn: 11496
2004-02-16 06:35:48 +00:00
Chris Lattner
18d1f19fba
Implement SimplifyCFG/PhiEliminate.ll
...
Having a proper 'select' instruction would allow the elimination of a lot
of the special case cruft in this patch, but we don't have one yet.
llvm-svn: 11307
2004-02-11 03:36:04 +00:00
Chris Lattner
838b845781
The hasConstantReferences predicate always returns false.
...
llvm-svn: 11301
2004-02-11 01:17:07 +00:00
Chris Lattner
fae8ab3088
rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
...
llvm-svn: 11202
2004-02-08 21:44:31 +00:00
Chris Lattner
df3c342a4c
Finegrainify namespacification
...
llvm-svn: 10727
2004-01-09 06:12:26 +00:00
Brian Gaeke
960707c335
Put all LLVM code into the llvm namespace, as per bug 109.
...
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
John Criswell
482202a601
Added LLVM project notice to the top of every C++ source file.
...
Header files will be on the way.
llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Misha Brukman
8b2bd4ed47
Fix spelling.
...
llvm-svn: 9027
2003-10-10 17:57:28 +00:00
Chris Lattner
04ecefe232
Eliminate support for the llvm.unwind intrinisic, using the Unwind instruction instead
...
llvm-svn: 8411
2003-09-08 19:44:26 +00:00
Chris Lattner
3f5823f131
Implement SimplifyCFG/InvokeEliminate.ll
...
llvm-svn: 8126
2003-08-24 18:36:16 +00:00
Chris Lattner
031340a551
Fix bug: SimplifyCFG/2003-08-17-BranchFoldOrdering.ll
...
llvm-svn: 7921
2003-08-17 19:41:53 +00:00
Chris Lattner
edc8c54e16
Fix bug: SimplifyCFG/2003-08-05-InvokeCrash.ll
...
Fix bug: SimplifyCFG/2003-08-05-MishandleInvoke.ll
llvm-svn: 7599
2003-08-05 16:27:44 +00:00
Chris Lattner
889f620841
Remove unnecesary &*'s
...
llvm-svn: 5872
2003-04-23 16:37:45 +00:00
Chris Lattner
569a57f9ff
Fix bug: SimplifyCFG/2003-03-07-DominateProblem.ll
...
llvm-svn: 5722
2003-03-07 18:13:41 +00:00
Chris Lattner
e54d214fcb
Implement CFGSimplify/PhiBlockMerge*.ll
...
llvm-svn: 5702
2003-03-05 21:36:33 +00:00
Chris Lattner
31116bafed
Implement testcase CFGSimplify/EqualPHIEdgeBlockMerge.ll
...
llvm-svn: 5699
2003-03-05 21:01:52 +00:00
Misha Brukman
632df28deb
Fix spelling of `propagate'.
...
llvm-svn: 4423
2002-10-29 23:06:16 +00:00
Chris Lattner
a704ac8a66
Changes to support PHINode::removeIncoming changes
...
llvm-svn: 4079
2002-10-08 21:36:33 +00:00
Chris Lattner
d6dcd8ec32
Fix bug: SimplifyCFG/2002-09-24-PHIAssertion.ll
...
llvm-svn: 3913
2002-09-24 16:09:17 +00:00
Chris Lattner
5325c5f340
Minor cleanups
...
llvm-svn: 3904
2002-09-24 00:09:26 +00:00
Chris Lattner
1cec4d90cd
Allow folding of basic blocks that have PHI nodes in them, fixing "bug":
...
test/Regression/Transforms/SimplifyCFG/2002-06-24-PHINode.ll
llvm-svn: 3128
2002-07-29 21:26:30 +00:00
Chris Lattner
fda72b1aad
*** empty log message ***
...
llvm-svn: 2777
2002-06-25 16:12:52 +00:00
Chris Lattner
466a049b67
Add implementation of SimplifyCFG
...
llvm-svn: 2701
2002-05-21 20:50:24 +00:00