summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaces.Jakub Staszak2012-05-061-60/+60
| | | | llvm-svn: 156257
* 153465 was incorrect. In this code we wanted to check that the pointer ↵Nadav Rotem2012-03-261-4/+3
| | | | | | operand is of pointer type (and not vector type). llvm-svn: 153468
* PR12357: The pointer was used before it was checked.Nadav Rotem2012-03-261-1/+3
| | | | llvm-svn: 153465
* llvm::SwitchInstStepan Dyatkovskiy2012-03-111-2/+2
| | | | | | | Renamed methods caseBegin, caseEnd and caseDefault with case_begin, case_end, and case_default. Added some notes relative to case iterators. llvm-svn: 152532
* Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:Stepan Dyatkovskiy2012-03-081-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*". ConstCaseIt is just a read-only iterator. CaseIt is read-write iterator; it allows to change case successor and case value. Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters. Main way of iterator usage looks like this: SwitchInst *SI = ... // intialize it somehow for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) { BasicBlock *BB = i.getCaseSuccessor(); ConstantInt *V = i.getCaseValue(); // Do something. } If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method. If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method. There are also related changes in llvm-clients: klee and clang. llvm-svn: 152297
* Remove some dead code and tidy things up now that vectors use ConstantDataVectorChris Lattner2012-02-061-8/+4
| | | | | | instead of always using ConstantVector. llvm-svn: 149912
* SwitchInst refactoring.Stepan Dyatkovskiy2012-02-011-5/+5
| | | | | | | | | | | | | | | | | The purpose of refactoring is to hide operand roles from SwitchInst user (programmer). If you want to play with operands directly, probably you will need lower level methods than SwitchInst ones (TerminatorInst or may be User). After this patch we can reorganize SwitchInst operands and successors as we want. What was done: 1. Changed semantics of index inside the getCaseValue method: getCaseValue(0) means "get first case", not a condition. Use getCondition() if you want to resolve the condition. I propose don't mix SwitchInst case indexing with low level indexing (TI successors indexing, User's operands indexing), since it may be dangerous. 2. By the same reason findCaseValue(ConstantInt*) returns actual number of case value. 0 means first case, not default. If there is no case with given value, ErrorIndex will returned. 3. Added getCaseSuccessor method. I propose to avoid usage of TerminatorInst::getSuccessor if you want to resolve case successor BB. Use getCaseSuccessor instead, since internal SwitchInst organization of operands/successors is hidden and may be changed in any moment. 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of these methods is to see how case successors are really mapped in TerminatorInst. 4.1 "resolveSuccessorIndex" was created if you need to level down from SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for given case successor. 4.2 "resolveCaseIndex" converts low level successors index to case index that curresponds to the given successor. Note: There are also related compatability fix patches for dragonegg, klee, llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. llvm-svn: 149481
* continue making the world safe for ConstantDataVector. At this point,Chris Lattner2012-01-271-4/+8
| | | | | | | we should (theoretically optimize and codegen ConstantDataVector as well as ConstantVector. llvm-svn: 149116
* Continue improving support for ConstantDataAggregate, and use theChris Lattner2012-01-261-16/+8
| | | | | | new methods recently added to (sometimes greatly!) simplify code. llvm-svn: 149024
* Add support for vectors of pointers.Nadav Rotem2011-12-051-2/+7
| | | | llvm-svn: 145801
* Fix a few more places where TargetData/TargetLibraryInfo is not being passed.Chad Rosier2011-12-021-1/+1
| | | | | | Add FIXMEs to places that are non-trivial to fix. llvm-svn: 145661
* Last bit of TargetLibraryInfo propagation. Also fixed a case for TargetDataChad Rosier2011-12-011-6/+11
| | | | | | | where it appeared beneficial to pass. More of rdar://10500969 llvm-svn: 145630
* Add support for sqrt, sqrtl, and sqrtf in TargetLibraryInfo. Disable Chad Rosier2011-11-291-0/+2
| | | | | | | | (fptrunc (sqrt (fpext x))) -> (sqrtf x) transformation if -fno-builtin is specified. rdar://10466410 llvm-svn: 145460
* Remove all remaining uses of Value::getNameStr().Benjamin Kramer2011-11-151-1/+1
| | | | llvm-svn: 144648
* Make sure we use the right insertion point when instcombine replaces a PHI ↵Eli Friedman2011-11-011-3/+4
| | | | | | with another instruction. (Specifically, don't insert an arbitrary instruction before a PHI.) Fixes PR11275. llvm-svn: 143437
* Add support for the Objective-C personality function to the instructionBill Wendling2011-10-171-2/+5
| | | | | | | | combining of the landingpad instruction. The ObjC personality function acts almost identically to the C++ personality function. In particular, it uses "null" as a "catch-all" value. llvm-svn: 142256
* Add a routine to swap branch instruction operands, and update anyChandler Carruth2011-10-171-6/+3
| | | | | | | | | | | | profile metadata at the same time. Use it to preserve metadata attached to a branch when re-writing it in InstCombine. Add metadata to the canonicalize_branch InstCombine test, and check that it is tranformed correctly. Reviewed by Nick Lewycky! llvm-svn: 142168
* Re-commit 141203, but much more conservative.Jim Grosbach2011-10-051-3/+3
| | | | | | | | Just pull the instruction name, but don't change the order of anything else. That keeps --debug happy and non-crashing, but doesn't change how the worklist gets built. llvm-svn: 141210
* Revert 141203. InstCombine is looping on unit tests.Jim Grosbach2011-10-051-9/+8
| | | | llvm-svn: 141209
* Update InstCombine worklist after instruction transform is complete.Jim Grosbach2011-10-051-8/+9
| | | | | | | | | | | | When updating the worklist for InstCombine, the Add/AddUsersToWorklist functions may access the instruction(s) being added, for debug output for example. If the instructions aren't yet added to the basic block, this can result in a crash. Finish the instruction transformation before adjusting the worklist instead. rdar://10238555 llvm-svn: 141203
* Inlining often produces landingpad instructions with repeatedDuncan Sands2011-09-301-0/+337
| | | | | | | | | | | | | | catch or repeated filter clauses. Teach instcombine a bunch of tricks for simplifying landingpad clauses. Currently the code only recognizes the GNU C++ and Ada personality functions, but that doesn't stop it doing a bunch of "generic" transforms which are hopefully fine for any real-world personality function. If these "generic" transforms turn out not to be generic, they can always be conditioned on the personality function. Probably someone should add the ObjC++ personality function. I didn't as I don't know anything about it. llvm-svn: 140852
* Clean up uses of switch instructions so they are not dependent on the ↵Eli Friedman2011-09-291-5/+11
| | | | | | operand ordering. Patch by Stepan Dyatkovskiy. llvm-svn: 140803
* Use Duncan's patch to delete the instructions in reverse order (minus the ↵Bill Wendling2011-09-041-6/+10
| | | | | | landingpad and terminator). llvm-svn: 139090
* Update comments to reflect reality.Bill Wendling2011-09-021-2/+1
| | | | llvm-svn: 139023
* Reduce indentation. No functionality change.Bill Wendling2011-09-011-17/+18
| | | | llvm-svn: 138968
* Change worklist driven deletion to be an iterative process.Bill Wendling2011-09-011-26/+5
| | | | | | Duncan noticed this! llvm-svn: 138967
* Resubmit with fix. Properly remove the instructions except for landingpad, ↵Bill Wendling2011-09-011-9/+28
| | | | | | which should be removed only when its invokes are. llvm-svn: 138932
* Submitted this too early.Bill Wendling2011-09-011-5/+0
| | | | llvm-svn: 138931
* Don't DCE the landingpad instruction.Bill Wendling2011-09-011-0/+5
| | | | | | The landingpad instruction can be removed only when its invokes are removed. llvm-svn: 138930
* Revert r137655. There is some question about whether the 'landingpad'Bill Wendling2011-08-171-1/+2
| | | | | | instruction should be marked as potentially reading and/or writing memory. llvm-svn: 137863
* Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'Bill Wendling2011-08-161-2/+1
| | | | | | check for a LandingPadInst. llvm-svn: 137745
* Don't sink the instruction to before a landingpad instruction.Bill Wendling2011-08-151-1/+1
| | | | llvm-svn: 137672
* Update instcombine for atomic load/store.Eli Friedman2011-08-151-1/+1
| | | | llvm-svn: 137664
* Duncan pointed out that the LandingPadInst might read memory. (It might alsoBill Wendling2011-08-151-3/+2
| | | | | | write to memory.) Marking it as such makes some checks for immobility go away. llvm-svn: 137655
* Don't try to sink the landingpad instruction. It's immobile.Bill Wendling2011-08-151-2/+3
| | | | llvm-svn: 137629
* This transform is not safe. Thanks to Eli for pointing that out!Nick Lewycky2011-08-141-8/+1
| | | | llvm-svn: 137575
* Don't attempt to add 'nsw' when intermediate instructions had no such guarantee.Nick Lewycky2011-08-141-4/+7
| | | | llvm-svn: 137572
* Teach instcombine to preserve the nsw bit by doing an after-the-fact analysisNick Lewycky2011-08-141-3/+54
| | | | | | when combining add and sub instructions. Patch by Pranav Bhandarkar! llvm-svn: 137570
* Small cleanups:Nick Lewycky2011-08-031-3/+2
| | | | | | | | | - use SmallVectorImpl& for the function argument. - ignore the operands on the GEP, even if they aren't constant! Much as we pretend the malloc succeeds, we pretend that malloc + whatever-you-GEP'd-by is not null. It's magic! llvm-svn: 136757
* Fix logical error when detecting lifetime intrinsics.Nick Lewycky2011-08-031-33/+34
| | | | | | | | | Don't replace a gep/bitcast with 'undef' because that will form a "free(undef)" which in turn means "unreachable". What we wanted was a no-op. Instead, analyze the whole tree and look for all the instructions we need to delete first, then delete them second, not relying on the use_list to stay consistent. llvm-svn: 136752
* Teach InstCombine that lifetime intrincs aren't a real user on the result of aNick Lewycky2011-08-021-11/+35
| | | | | | malloc call. llvm-svn: 136732
* Add a small gep optimization I noticed was missing while reading some IL.Rafael Espindola2011-07-311-11/+13
| | | | llvm-svn: 136585
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-6/+4
| | | | llvm-svn: 135904
* Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to useJay Foad2011-07-221-10/+7
| | | | | | ArrayRef. llvm-svn: 135761
* Convert SimplifyGEPInst to use ArrayRef.Jay Foad2011-07-191-1/+1
| | | | llvm-svn: 135482
* Migrate LLVM and Clang to use the new makeArrayRef(...) functions where ↵Frits van Bommel2011-07-181-2/+2
| | | | | | | | previously explicit non-default constructors were used. Mostly mechanical with some manual reformatting. llvm-svn: 135390
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-17/+17
| | | | llvm-svn: 135375
* Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.Jay Foad2011-07-131-5/+5
| | | | llvm-svn: 135040
* Don't duplicate the work done by a gep into a "bitcast" if the gep hasRafael Espindola2011-07-111-0/+8
| | | | | | | | more than one use. Fixes PR10322. llvm-svn: 134883
* Final step of instcombine debuginfo; switch a couple more places over to ↵Eli Friedman2011-05-271-2/+3
| | | | | | InsertNewInstWith, and use setDebugLoc for the cases which can't be easily handled by the automated mechanisms. llvm-svn: 132167
OpenPOWER on IntegriCloud