summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
...
* Completely disable the optimization I added in r121680 untilChris Lattner2010-12-131-3/+6
| | | | | | | I can track down a miscompile. This should bring the buildbots back to life llvm-svn: 121693
* Make simplifycfg reprocess newly formed "br (cond1 | cond2)" conditionsChris Lattner2010-12-131-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when simplifying, allowing them to be eagerly turned into switches. This is the last step required to get "Example 7" from this blog post: http://blog.regehr.org/archives/320 On X86, we now generate this machine code, which (to my eye) seems better than the ICC generated code: _crud: ## @crud ## BB#0: ## %entry cmpb $33, %dil jb LBB0_4 ## BB#1: ## %switch.early.test addb $-34, %dil cmpb $58, %dil ja LBB0_3 ## BB#2: ## %switch.early.test movzbl %dil, %eax movabsq $288230376537592865, %rcx ## imm = 0x400000017001421 btq %rax, %rcx jb LBB0_4 LBB0_3: ## %lor.rhs xorl %eax, %eax ret LBB0_4: ## %lor.end movl $1, %eax ret llvm-svn: 121690
* make this logic a bit simpler.Chris Lattner2010-12-131-21/+20
| | | | llvm-svn: 121689
* split all the guts of SimplifyCFGOpt::run out into one functionChris Lattner2010-12-131-374/+441
| | | | | | per terminator kind. llvm-svn: 121688
* fix a bug in r121680 that upset the various buildbots.Chris Lattner2010-12-131-0/+7
| | | | llvm-svn: 121687
* refactor the speculative execution logic to be factored into the cond branch ↵Chris Lattner2010-12-131-26/+22
| | | | | | | | code instead of doing a cfg search for every block simplified. llvm-svn: 121686
* simplify a bunch of code.Chris Lattner2010-12-131-15/+4
| | | | llvm-svn: 121685
* move HoistThenElseCodeToIf up to a more logical and efficient-to-handle place.Chris Lattner2010-12-131-7/+11
| | | | llvm-svn: 121684
* move 'MergeBlocksIntoPredecessor' call earlier. UseChris Lattner2010-12-131-20/+9
| | | | | | getSinglePredecessor to simplify code. llvm-svn: 121683
* factor new code out to a SimplifyBranchOnICmpChain helper function.Chris Lattner2010-12-131-77/+91
| | | | llvm-svn: 121681
* enhance the "change or icmp's into switch" xform to handle one value in an Chris Lattner2010-12-131-3/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'or sequence' that it doesn't understand. This allows us to optimize something insane like this: int crud (unsigned char c, unsigned x) { if(((((((((( (int) c <= 32 || (int) c == 46) || (int) c == 44) || (int) c == 58) || (int) c == 59) || (int) c == 60) || (int) c == 62) || (int) c == 34) || (int) c == 92) || (int) c == 39) != 0) foo(); } into: define i32 @crud(i8 zeroext %c, i32 %x) nounwind ssp noredzone { entry: %cmp = icmp ult i8 %c, 33 br i1 %cmp, label %if.then, label %switch.early.test switch.early.test: ; preds = %entry switch i8 %c, label %if.end [ i8 39, label %if.then i8 44, label %if.then i8 58, label %if.then i8 59, label %if.then i8 60, label %if.then i8 62, label %if.then i8 46, label %if.then i8 92, label %if.then i8 34, label %if.then ] by pulling the < comparison out ahead of the newly formed switch. llvm-svn: 121680
* merge two very similar functions into one that has a bool argument.Chris Lattner2010-12-131-47/+26
| | | | llvm-svn: 121678
* don't bother handling non-canonical icmp'sChris Lattner2010-12-131-11/+9
| | | | llvm-svn: 121676
* inline a function, making the result much simpler.Chris Lattner2010-12-131-27/+11
| | | | llvm-svn: 121675
* Fix my previous patch to handle a degenerate case that the llvm-gccChris Lattner2010-12-131-0/+16
| | | | | | bootstrap buildbot tripped over. llvm-svn: 121674
* convert some methods to be static functionsChris Lattner2010-12-131-25/+23
| | | | llvm-svn: 121673
* zap two more std::sorts.Chris Lattner2010-12-131-2/+2
| | | | llvm-svn: 121672
* fix a fairly serious oversight with switch formation fromChris Lattner2010-12-131-1/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | or'd conditions. Previously we'd compile something like this: int crud (unsigned char c) { return c == 62 || c == 34 || c == 92; } into: switch i8 %c, label %lor.rhs [ i8 62, label %lor.end i8 34, label %lor.end ] lor.rhs: ; preds = %entry %cmp8 = icmp eq i8 %c, 92 br label %lor.end lor.end: ; preds = %entry, %entry, %lor.rhs %0 = phi i1 [ true, %entry ], [ %cmp8, %lor.rhs ], [ true, %entry ] %lor.ext = zext i1 %0 to i32 ret i32 %lor.ext which failed to merge the compare-with-92 into the switch. With this patch we simplify this all the way to: switch i8 %c, label %lor.rhs [ i8 62, label %lor.end i8 34, label %lor.end i8 92, label %lor.end ] lor.rhs: ; preds = %entry br label %lor.end lor.end: ; preds = %entry, %entry, %entry, %lor.rhs %0 = phi i1 [ true, %entry ], [ false, %lor.rhs ], [ true, %entry ], [ true, %entry ] %lor.ext = zext i1 %0 to i32 ret i32 %lor.ext which is much better for codegen's switch lowering stuff. This kicks in 33 times on 176.gcc (for example) cutting 103 instructions off the generated code. llvm-svn: 121671
* simplify code and reduce indentationChris Lattner2010-12-131-32/+30
| | | | llvm-svn: 121670
* convert an std::sort to array_pod_sort.Chris Lattner2010-12-131-2/+8
| | | | llvm-svn: 121669
* move the "br (X == 0 | X == 1), T, F" -> switch optimization to a newChris Lattner2010-12-131-57/+56
| | | | | | | | | | | location in simplifycfg. In the old days, SimplifyCFG was never run on the entry block, so we had to scan over all preds of the BB passed into simplifycfg to do this xform, now we can just check blocks ending with a condbranch. This avoids a scan over all preds of every simplified block, which should be a significant compile-time perf win on functions with lots of edges. No functionality change. llvm-svn: 121668
* reduce indentation and generally simplify code, no functionality change.Chris Lattner2010-12-131-333/+309
| | | | llvm-svn: 121667
* use getFirstNonPHIOrDbg to simplify this code.Chris Lattner2010-12-131-9/+5
| | | | llvm-svn: 121664
* Generalize the and-icmp-select instcombine further by allowing selects of ↵Benjamin Kramer2010-12-111-4/+22
| | | | | | | | | | | the form (x & 2^n) ? 2^m+C : C we can offset both arms by C to get the "(x & 2^n) ? 2^m : 0" form, optimize the select to a shift and apply the offset afterwards. llvm-svn: 121609
* Factor the (x & 2^n) ? 2^m : 0 instcombine into its own method and generalize itBenjamin Kramer2010-12-111-26/+54
| | | | | | to catch cases where n != m with a shift. llvm-svn: 121608
* enhance memcpyopt to zap memcpy's that have the same src/dst.Chris Lattner2010-12-091-4/+13
| | | | llvm-svn: 121362
* fix PR8753, eliminating a case where we'd infinitely make a Chris Lattner2010-12-091-0/+8
| | | | | | | substitution because it doesn't actually change the IR. Patch by Jakub Staszak! llvm-svn: 121361
* Really check that the bits that will become zero are actually already zeroDan Gohman2010-12-091-2/+1
| | | | | | before eliminating the operation that zeros them. This fixes rdar://8739316. llvm-svn: 121353
* Remove some dead code from the jump threading pass.Frits van Bommel2010-12-071-141/+0
| | | | | | The last uses of these functions were removed in r113852 when LazyValueInfo was permanently enabled and removed the need for them. llvm-svn: 121133
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-074-31/+28
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121120
* reapply r121100 with a tweak to constant fold ConstExprs with TargetDataChris Lattner2010-12-071-8/+95
| | | | | | | | (if available) as we go so that we get simple constantexprs not insane ones. This fixes the failure of clang/test/CodeGenCXX/virtual-base-ctor.cpp that the previous iteration of this patch had. llvm-svn: 121111
* Temporarily revert r121100 as it's causing clang to failEric Christopher2010-12-071-85/+5
| | | | | | CodeGenCXX/virtual-base-ctor.cpp. llvm-svn: 121102
* fix PR8710 - teach global opt that some constantexprs are too complex toChris Lattner2010-12-071-5/+85
| | | | | | put in a global variable's initializer. llvm-svn: 121100
* Implement jump threading of 'indirectbr' by keeping track of whether we're ↵Frits van Bommel2010-12-061-46/+80
| | | | | | looking for ConstantInt*s or BlockAddress*s. llvm-svn: 121066
* replace a linear scan with a symtab lookup, reduce indentation.Chris Lattner2010-12-061-38/+38
| | | | | | No functionality change. llvm-svn: 121042
* Use a stronger predicate here, pointed out by DuncanChris Lattner2010-12-061-1/+1
| | | | llvm-svn: 121040
* add some DEBUG statements.Chris Lattner2010-12-061-3/+14
| | | | llvm-svn: 121038
* Fix PR8735, a really terrible problem in the inliner's "alloca merging"Chris Lattner2010-12-061-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | optimization. Consider: static void foo() { A = alloca ... } static void bar() { B = alloca ... call foo(); } void main() { bar() } The inliner proceeds bottom up, but lets pretend it decides not to inline foo into bar. When it gets to main, it inlines bar into main(), and says "hey, I just inlined an alloca "B" into main, lets remember that. Then it keeps going and finds that it now contains a call to foo. It decides to inline foo into main, and says "hey, foo has an alloca A, and I have an alloca B from another inlined call site, lets reuse it". The problem with this of course, is that the lifetime of A and B are nested, not disjoint. Unfortunately I can't create a reasonable testcase for this: the one in the PR is both huge and extremely sensitive, because you minor tweaks end up causing foo to get inlined into bar too early. We already have tests for the basic alloca merging optimization and this does not break them. llvm-svn: 120995
* improve commentChris Lattner2010-12-061-2/+1
| | | | llvm-svn: 120994
* improve -debug output and comments a little.Chris Lattner2010-12-061-3/+5
| | | | llvm-svn: 120993
* Fix PR8728, a miscompilation I recently introduced. When optimizingChris Lattner2010-12-061-5/+62
| | | | | | | | | | | | | | | | | | | | | memcpy's like: memcpy(A, B) memcpy(A, C) we cannot delete the first memcpy as dead if A and C might be aliases. If so, we actually get: memcpy(A, B) memcpy(A, A) which is not correct to transform into: memcpy(A, A) This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks Jakub! llvm-svn: 120974
* Refactor jump threading.Frits van Bommel2010-12-051-69/+73
| | | | | | | Should have no functional change other than the order of two transformations that are mutually-exclusive and the exact formatting of debug output. Internally, it now stores the ConstantInt*s as Constant*s, and actual undef values instead of nulls. llvm-svn: 120946
* Remove trailing whitespace.Frits van Bommel2010-12-051-208/+208
| | | | llvm-svn: 120945
* Teach SimplifyCFG to turnFrits van Bommel2010-12-051-2/+72
| | | | | | | | | (indirectbr (select cond, blockaddress(@fn, BlockA), blockaddress(@fn, BlockB))) into (br cond, BlockA, BlockB). llvm-svn: 120943
* PR5207: Rename overloaded APInt methods set(), clear(), flip() toJay Foad2010-12-013-21/+21
| | | | | | setAllBits(), setBit(unsigned), etc. llvm-svn: 120564
* fix a bozo bug I introduced in r119930, causing a miscompile ofChris Lattner2010-12-011-1/+2
| | | | | | | 20040709-1.c from the gcc testsuite. I was using the size of a pointer instead of the pointee. This fixes rdar://8713376 llvm-svn: 120519
* Enhance DSE to handle the variable index case in PR8657.Chris Lattner2010-11-301-2/+31
| | | | llvm-svn: 120498
* teach DSE to use GetPointerBaseWithConstantOffset to analyzeChris Lattner2010-11-301-16/+49
| | | | | | | | may-aliasing stores that partially overlap with different base pointers. This implements PR6043 and the non-variable part of PR8657 llvm-svn: 120485
* move GetPointerBaseWithConstantOffset out of GVN into ValueTracking.hChris Lattner2010-11-301-58/+12
| | | | llvm-svn: 120476
* remove a fixed fixmeChris Lattner2010-11-301-2/+0
| | | | llvm-svn: 120474
OpenPOWER on IntegriCloud