summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
Commit message (Collapse)AuthorAgeFilesLines
...
* reinstate my patch: the miscompile was caused by an inverted branch in theChris Lattner2010-12-131-27/+48
| | | | | | 'and' case. llvm-svn: 121695
* Completely disable the optimization I added in r121680 untilChris Lattner2010-12-131-27/+28
| | | | | | | 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-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* fix a bug in r121680 that upset the various buildbots.Chris Lattner2010-12-131-0/+29
| | | | llvm-svn: 121687
* make these tests a bit less fragileChris Lattner2010-12-132-12/+6
| | | | llvm-svn: 121682
* enhance the "change or icmp's into switch" xform to handle one value in an Chris Lattner2010-12-131-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | '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 testsChris Lattner2010-12-132-30/+42
| | | | llvm-svn: 121679
* Fix my previous patch to handle a degenerate case that the llvm-gccChris Lattner2010-12-131-0/+23
| | | | | | bootstrap buildbot tripped over. llvm-svn: 121674
* fix a fairly serious oversight with switch formation fromChris Lattner2010-12-131-1/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Teach SimplifyCFG to turnFrits van Bommel2010-12-051-0/+118
| | | | | | | | | (indirectbr (select cond, blockaddress(@fn, BlockA), blockaddress(@fn, BlockB))) into (br cond, BlockA, BlockB). llvm-svn: 120943
* Factor out Instruction::isSafeToSpeculativelyExecute's code forDan Gohman2010-11-111-0/+94
| | | | | | | | | | | | testing for dereferenceable pointers into a helper function, isDereferenceablePointer. Teach it how to reason about GEPs with simple non-zero indices. Also eliminate ArgumentPromtion's IsAlwaysValidPointer, which didn't check for weak externals or out of range gep indices. llvm-svn: 118840
* Fix PR8445: a block with no predecessors may be the entry block, in which caseDuncan Sands2010-10-241-0/+6
| | | | | | | | | it isn't unreachable and should not be zapped. The check for the entry block was missing in one case: a block containing a unwind instruction. While there, do some small cleanups: "M" is not a great name for a Function* (it would be more appropriate for a Module*), change it to "Fn"; use Fn in more places. llvm-svn: 117224
* Correct bogus module triple specifications.Duncan Sands2010-08-301-1/+1
| | | | llvm-svn: 112469
* Instead, teach SimplifyCFG to trim non-address-taken blocks fromDan Gohman2010-08-161-0/+13
| | | | | | indirectbr destination lists. llvm-svn: 111122
* Teach SimplifyCFG how to simplify indirectbr instructions.Dan Gohman2010-08-142-1/+51
| | | | | | | | | | | - Eliminate redundant successors. - Convert an indirectbr with one successor into a direct branch. Also, generalize SimplifyCFG to be able to be run on a function entry block. It knows quite a few simplifications which are applicable to the entry block, and it only needs a few checks to avoid trouble with the entry block. llvm-svn: 111060
* Test case for r105914.Benjamin Kramer2010-06-131-0/+11
| | | | llvm-svn: 105915
* make simplifycfg insert an llvm.trap before the 'unreachable' it introducesChris Lattner2010-05-081-3/+17
| | | | | | | | | | | | | | | | | | | | | when it detects undefined behavior. llvm.trap generally codegens into some thing really small (e.g. a 2 byte ud2 instruction on x86) and debugging this sort of thing is "nontrivial". For example, we now compile: void foo() { *(int*)0 = 42; } into: _foo: pushl %ebp movl %esp, %ebp ud2 Some may even claim that this is a security hole, though that seems dubious to me. This addresses rdar://7958343 - Optimizing away null dereference potentially allows arbitrary code execution llvm-svn: 103356
* testcase for r99914, provided by baldrick!Gabor Greif2010-03-311-0/+18
| | | | llvm-svn: 100043
* Floating-point add, sub, and mul are now spelled fadd, fsub, and fmul,Dan Gohman2010-03-021-7/+7
| | | | | | respectively. llvm-svn: 97531
* Teach SimplifyCFG about magic pointer constants.Jakob Stoklund Olesen2010-02-051-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Weird code sometimes uses pointer constants other than null. This patch teaches SimplifyCFG to build switch instructions in those cases. Code like this: void f(const char *x) { if (!x) puts("null"); else if ((uintptr_t)x == 1) puts("one"); else if (x == (char*)2 || x == (char*)3) puts("two"); else if ((intptr_t)x == 4) puts("four"); else puts(x); } Now becomes a switch: define void @f(i8* %x) nounwind ssp { entry: %magicptr23 = ptrtoint i8* %x to i64 ; <i64> [#uses=1] switch i64 %magicptr23, label %if.else16 [ i64 0, label %if.then i64 1, label %if.then2 i64 2, label %if.then9 i64 3, label %if.then9 i64 4, label %if.then14 ] Note that LLVM's own DenseMap uses magic pointers. llvm-svn: 95439
* Delete useless trailing semicolons.Dan Gohman2010-01-056-6/+6
| | | | llvm-svn: 92740
* fix two bogus tests that the asmparser now rejects.Chris Lattner2009-12-301-1/+1
| | | | llvm-svn: 92303
* Implement PR5795 by merging duplicated return blocks. This could go furtherChris Lattner2009-12-221-0/+19
| | | | | | | by merging all returns in a function into a single one, but simplifycfg currently likes to duplicate the return (an unfortunate choice!) llvm-svn: 91890
* convert to filecheckChris Lattner2009-12-221-5/+15
| | | | llvm-svn: 91889
* Optimize test more.Dan Gohman2009-11-101-1/+1
| | | | llvm-svn: 86714
* optimize testChris Lattner2009-11-101-1/+1
| | | | llvm-svn: 86672
* Revert r85667. LoopUnroll currently can't call utility functions whichDan Gohman2009-10-311-2/+0
| | | | | | | auto-update the DominatorTree because it doesn't keep the DominatorTree current while it works. llvm-svn: 85670
* Merge the enhancements from LoopUnroll's FoldBlockIntoPredecessor intoDan Gohman2009-10-311-0/+2
| | | | | | | MergeBlockIntoPredecessor. This makes SimplifyCFG slightly more aggressive, and makes it unnecessary for LoopUnroll to have its own copy of this code. llvm-svn: 85667
* Add a testcase for the recent duplicate PHI elimination changes.Dan Gohman2009-10-301-0/+21
| | | | llvm-svn: 85636
* if basic blocks are destroyed while there are *just* BlockAddress' hanging Chris Lattner2009-10-301-2/+7
| | | | | | | around, then zap them. This is analogous to dangling constantexprs hanging off functions. llvm-svn: 85627
* change simplifycfg to not duplicate 'unwind' instructions. HopefullyChris Lattner2009-10-131-3/+18
| | | | | | | this will increase the likelihood of common code getting sunk towards the unwind. llvm-svn: 83996
* convert to filecheckChris Lattner2009-10-131-5/+5
| | | | llvm-svn: 83995
* rename testChris Lattner2009-10-131-0/+0
| | | | llvm-svn: 83994
* Change tests from "opt %s" to "opt < %s" so that opt doesn't see theDan Gohman2009-09-1160-60/+60
| | | | | | | | input filename so that opt doesn't print the input filename in the output so that grep lines in the tests don't unintentionally match strings in the input filename. llvm-svn: 81537
* fix a bunch of spurious failures for people whose home directoryChris Lattner2009-09-1113-16/+14
| | | | | | is sabre. llvm-svn: 81528
* Convert a few more opt | llvm-dis to opt -S.Dan Gohman2009-09-081-1/+1
| | | | llvm-svn: 81261
* Use opt -S instead of piping bitcode output through llvm-dis.Dan Gohman2009-09-0851-52/+52
| | | | llvm-svn: 81257
* Change these tests to feed the assembly files to opt directly, insteadDan Gohman2009-09-0877-78/+78
| | | | | | of using llvm-as, now that opt supports this. llvm-svn: 81226
* Reapply 79977.Devang Patel2009-08-281-2/+0
| | | | | | Use MDNodes to encode debug info in llvm IR. llvm-svn: 80406
* Revert 79977. It causes llvm-gcc bootstrap failures on some platforms.Devang Patel2009-08-261-0/+2
| | | | llvm-svn: 80073
* Update DebugInfo interface to use metadata, instead of special named ↵Devang Patel2009-08-251-2/+0
| | | | | | | | llvm.dbg.... global variables, to encode debugging information in llvm IR. This is mostly a mechanical change that tests metadata support very well. This change speeds up llvm-gcc by more then 6% at "-O0 -g" (measured by compiling InstructionCombining.cpp!) llvm-svn: 79977
* Fix for PR3016: detect the tricky case, where there are Eli Friedman2009-08-161-1/+0
| | | | | | | | | | | | | | | | unfoldable references to a PHI node in the block being folded, and disable the transformation in that case. The correct transformation of such PHI nodes depends on whether BB dominates Succ, and dominance is expensive to compute here. (Alternatively, it's possible to check whether any uses are live, but that's also essentially a dominance calculation. Another alternative is to use reg2mem, but it probably isn't a good idea to use that in simplifycfg.) Also, remove some incorrect code from CanPropagatePredecessorsForPHIs which is made unnecessary with this patch: it didn't consider the case where a PHI node in BB has multiple uses. llvm-svn: 79174
* Revert 75571; I'm convinced this isn't the right thing to do.Dale Johannesen2009-07-141-11/+0
| | | | llvm-svn: 75642
* Don't delete asm's just because their inputs are undefined;Dale Johannesen2009-07-141-0/+11
| | | | | | xor R, R is a common and valid idiom for zeroing a register, for example. llvm-svn: 75571
* Fix the crash in this test. This is basically the sameDale Johannesen2009-06-151-0/+557
| | | | | | | | problem addressed in 31284, but the patch there only addressed the case where an invoke is the first thing in a block. llvm-svn: 73416
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-044-10/+10
| | | | | | | | | | | | | | | integer and floating-point opcodes, introducing FAdd, FSub, and FMul. For now, the AsmParser, BitcodeReader, and IRBuilder all preserve backwards compatability, and the Core LLVM APIs preserve backwards compatibility for IR producers. Most front-ends won't need to change immediately. This implements the first step of the plan outlined here: http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt llvm-svn: 72897
* Testcase for 71688.Dale Johannesen2009-05-131-0/+47
| | | | llvm-svn: 71691
* While hoisting instruction to speculatively execute simple bb, ignore dbg ↵Devang Patel2009-03-061-0/+108
| | | | | | intrinsics. llvm-svn: 66255
* Ignore dbg info intrinsics when folding conditional branch to Zhou Sheng2009-02-261-0/+70
| | | | | | conditional branch predecessors. llvm-svn: 65509
* Don't block basic block with only SwitchInst to fold into predecessors.Zhou Sheng2009-02-251-0/+116
| | | | llvm-svn: 65456
OpenPOWER on IntegriCloud