aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/CodeGenPrepare.cpp
AgeCommit message (Collapse)Author
2009-01-12Rename getABITypeSize to getTypePaddedSize, asDuncan Sands
suggested by Chris. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62099 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-05Find loop back edges only after empty blocks are eliminated.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61752 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-19- CodeGenPrepare does not split loop back edges but it only knows about back ↵Evan Cheng
edges of single block loops. It now does a DFS walk to find loop back edges. - Use SplitBlockPredecessors to factor out common predecessors of the critical edge destination. This is disabled for now due to some regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28don't call MergeBasicBlockIntoOnlyPred on a block whose onlyChris Lattner
predecessor is itself. This doesn't make sense, and this is a dead infinite loop anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60210 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27remove doConstantPropagation and dceInstruction, they are justChris Lattner
wrappers around the interesting code and use an obscure iterator abstraction that dates back many many years. Move EraseDeadInstructions to Transforms/Utils and name it RecursivelyDeleteTriviallyDeadInstructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60191 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27defensive patch: if CGP is merging a block with the entry block, make sureChris Lattner
it ends up being the entry block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60180 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27Use the new MergeBasicBlockIntoOnlyPred function.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60163 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26Turn on my codegen prepare heuristic by default. It doesn't affect Chris Lattner
performance in most cases on the Grawp tester, but does speed some things up (like shootout/hash by 15%). This also doesn't impact compile time in a noticable way on the Grawp tester. It also, of course, gets the testcase it was designed for right :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60120 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26teach the new heuristic how to handle inline asm.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60088 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26Improve ValueAlreadyLiveAtInst with a cheap and dirty, but effectiveChris Lattner
heuristic: the value is already live at the new memory operation if it is used by some other instruction in the memop's block. This is cheap and simple to compute (moreso than full liveness). This improves the new heuristic even more. For example, it cuts two out of three new instructions out of 255.vortex:DbmFileInGrpHdr, which is one of the functions that the heuristic regressed. This overall eliminates another 40 instructions from 403.gcc and visibly reduces register pressure in 255.vortex (though this only actually ends up saving the 2 instructions from the whole program). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60084 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26Start rewroking a subpiece of the profitability heuristic to beChris Lattner
phrased in terms of liveness instead of as a horrible hack. :) In pratice, this doesn't change the generated code for either 255.vortex or 403.gcc, but it could cause minor code changes in theory. This is framework for coming changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60082 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26add a comment, make save/restore logic more obvious.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60076 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26This adds in some code (currently disabled unless you pass Chris Lattner
-enable-smarter-addr-folding to llc) that gives CGP a better cost model for when to sink computations into addressing modes. The basic observation is that sinking increases register pressure when part of the addr computation has to be available for other reasons, such as having a use that is a non-memory operation. In cases where it works, it can substantially reduce register pressure. This code is currently an overall win on 403.gcc and 255.vortex (the two things I've been looking at), but there are several things I want to do before enabling it by default: 1. This isn't doing any caching of results, so it is much slower than it could be. It currently slows down release-asserts llc by 1.7% on 176.gcc: 27.12s -> 27.60s. 2. This doesn't think about inline asm memory operands yet. 3. The cost model botches the case when the needed value is live across the computation for other reasons. I'll continue poking at this, and eventually turn it on as llcbeta. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60074 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26Teach CodeGenPrepare to look through Bitcast instructions when attempting toChris Lattner
optimize addressing modes. This allows us to optimize things like isel-sink2.ll into: movl 4(%esp), %eax cmpb $0, 4(%eax) jne LBB1_2 ## F LBB1_1: ## TB movl $4, %eax ret LBB1_2: ## F movzbl 7(%eax), %eax ret instead of: _test: movl 4(%esp), %eax cmpb $0, 4(%eax) leal 4(%eax), %eax jne LBB1_2 ## F LBB1_1: ## TB movl $4, %eax ret LBB1_2: ## F movzbl 3(%eax), %eax ret This shrinks (e.g.) 403.gcc from 1133510 to 1128345 lines of .s. Note that the 2008-10-16-SpillerBug.ll testcase is dubious at best, I doubt it is really testing what it thinks it is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60068 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25Teach MatchScaledValue to handle Scales by 1 with MatchAddr (whichChris Lattner
can recursively match things) and scales by 0 by ignoring them. This triggers once in 403.gcc, saving 1 (!!!!) instruction in the whole huge app. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60013 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25significantly refactor all the addressing mode matching logicChris Lattner
into a new AddressingModeMatcher class. This makes it easier to reason about and reduces passing around of stuff, but has no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60012 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25refactor all the constantexpr/instruction handling code out into a Chris Lattner
new FindMaximalLegalAddressingModeForOperation helper method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60011 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25another minor tweakChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60010 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25minor cleanups no functionality change.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60009 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24rearrange and tidy some code, no functionality change.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59990 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24minor cleanups to debug code, no functionality change.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59989 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24reenable the right part of the code.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24revert an accidental commit, this fixes the regression on ↵Chris Lattner
test/CodeGen/X86/isel-sink.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59976 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Fix 3113: If we have a dead cyclic PHI, replace the whole thingChris Lattner
with an undef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59972 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-24Commit CodeGenPrepare.cpp changes which was accidentially left out of 56526.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56549 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-24Fix fallout in CodeGenPrepare from 56526. Will likely need more work.Eric Christopher
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56546 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-04Tidy up several unbeseeming casts from pointer to intptr_t.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55779 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-27Rename SDOperand to SDValue.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54128 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08Remove comparison methods for MVT. The main causeDuncan Sands
of apint codegen failure is the DAG combiner doing the wrong thing because it was comparing MVT's using < rather than comparing the number of bits. Removing the < method makes this mistake impossible to commit. Instead, add helper methods for comparing bits and use them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52098 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06Wrap MVT::ValueType in a struct to get type safetyDuncan Sands
and better control the abstraction. Rename the type to MVT. To update out-of-tree patches, the main thing to do is to rename MVT::ValueType to MVT, and rewrite expressions like MVT::getSizeInBits(VT) in the form VT.getSizeInBits(). Use VT.getSimpleVT() to extract a MVT::SimpleValueType for use in switch statements (you will get an assert failure if VT is an extended value type - these shouldn't exist after type legalization). This results in a small speedup of codegen and no new testsuite failures (x86-64 linux). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52044 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places toDan Gohman
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-16API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. ↵Gabor Greif
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-13Clean up the use of static and anonymous namespaces. This turned upDan Gohman
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-08Improve pass documentation and comments.Gordon Henriksen
Patch by Matthijs Kooijman! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50861 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-27Implement a signficant optimization for inline asm:Chris Lattner
When choosing between constraints with multiple options, like "ir", test to see if we can use the 'i' constraint and go with that if possible. This produces more optimal ASM in all cases (sparing a register and an instruction to load it), and fixes inline asm like this: void test () { asm volatile (" %c0 %1 " : : "imr" (42), "imr"(14)); } Previously we would dump "42" into a memory location (which is ok for the 'm' constraint) which would cause a problem because the 'c' modifier is not valid on memory operands. Isn't it great how inline asm turns 'missed optimization' into 'compile failed'?? Incidentally, this was the todo in PowerPC/2007-04-24-InlineAsm-I-Modifier.ll Please do NOT pull this into Tak. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50315 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-27Move a bunch of inline asm code out of line.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50313 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25Remove the code from CodeGenPrepare that moved getresult instructionsDan Gohman
to the block that defines their operands. This doesn't work in the case that the operand is an invoke, because invoke is a terminator and must be the last instruction in a block. Replace it with support in SelectionDAGISel for copying struct values into sequences of virtual registers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50279 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-06silence a warning when assertions are disabled.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49283 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-21Handle getresult instructions in different basic blocksDan Gohman
from their aggregate operands by moving the getresult instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48657 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-19Remove dead options.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48556 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26fix http://llvm.org/bugs/show_bug.cgi?id=2097Gabor Greif
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47615 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26Fix for pr2093: direct operands aren't necessarily addresses, so don't Eli Friedman
try to simplify them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47610 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26Fix PR2076. CodeGenPrepare now sinks address computation for inline asm memoryEvan Cheng
operands into inline asm block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47589 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-20Make sure the caller doesn't use freed memory.Duncan Sands
Fixes PR1935. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46203 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29Remove attribution from file headers, per discussion on llvmdev.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-25Don't break critical edges for single-bb loops, this helps with PR1877, thoughChris Lattner
it is only a partial fix. This change is noise for most programs, but speeds up Shootout-C++/matrix by 20%, Ptrdist/ks by 24%, smg2000 by 8%, hexxagon by 9%, bzip2 by 9% (not sure I trust this), ackerman by 13%, etc. OTOH, it slows down Shootout/fib2 by 40% (I'll update PR1877 with this info). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45354 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-24add a -backedge-hack llc-beta option to codegenprepare.Chris Lattner
When specified, don't split backedges of single-bb loops. This helps address PR1877 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45344 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-13Fix typo.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44997 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-13Be extra careful with extension use optimation. Now turned on by default.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44981 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-12Don't muck with phi nodes; bug fixes.Evan Cheng
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44905 91177308-0d34-0410-b5e6-96231b3b80d8