summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduce isOpaqueTy and use it rather than isa<OpaqueType>. Also, move someDuncan Sands2010-02-161-1/+1
| | | | | | methods to try to have the type predicates be more logically positioned. llvm-svn: 96349
* There are two ways of checking for a given type, for example isa<PointerType>(T)Duncan Sands2010-02-161-9/+9
| | | | | | | and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. llvm-svn: 96344
* Uniformize the names of type predicates: rather than having isFloatTy andDuncan Sands2010-02-151-13/+13
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* Add support for a union type in LLVM IR. Patch by Talin!Chris Lattner2010-02-121-0/+6
| | | | llvm-svn: 96011
* Canonicalize sizeof and alignof on pointer types to a canonicalDan Gohman2010-02-101-0/+19
| | | | | | pointer type. llvm-svn: 95769
* Factor out alignof expression folding into a separate function andDan Gohman2010-02-021-26/+69
| | | | | | generalize it to handle more cases. llvm-svn: 95045
* eliminate a bunch of pointless LLVMContext arguments.Chris Lattner2010-02-011-151/+124
| | | | llvm-svn: 95001
* Fix typo "of" -> "or" and change the way a line was formatted to fitDuncan Sands2010-02-011-2/+2
| | | | | | into 80 columns to match my artistic preferences. llvm-svn: 95000
* fix PR6195, a bug constant folding scalar -> vector compares.Chris Lattner2010-02-011-3/+5
| | | | llvm-svn: 94997
* fix PR6197 - infinite recursion in ipsccp due to block addressesChris Lattner2010-02-011-19/+47
| | | | | | evaluateICmpRelation wasn't handling blockaddress. llvm-svn: 94993
* Generalize target-independent folding rules for sizeof to handle moreDan Gohman2010-02-011-24/+169
| | | | | | | | | | | | | | | | | | | cases, and implement target-independent folding rules for alignof and offsetof. Also, reassociate reassociative operators when it leads to more folding. Generalize ScalarEvolution's isOffsetOf to recognize offsetof on arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr to getOffsetOfExpr, for consistency with analagous ConstantExpr routines. Make the target-dependent folder promote GEP array indices to pointer-sized integers, to make implicit casting explicit and exposed to subsequent folding. And add a bunch of testcases for this new functionality, and a bunch of related existing functionality. llvm-svn: 94987
* Remove the folding ruleDan Gohman2010-01-281-22/+0
| | | | | | | | | | | | | | | | | getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1) to inttoptr (i64 0 to i8*) from the VMCore constant folder. It didn't handle sign-extension properly in the case where the source integer is smaller than a pointer size. And, it relied on an assumption about sizeof(i8). The Analysis constant folder still folds these kinds of things; it has access to TargetData, so it can do them right. Add a testcase which tests that the VMCore constant folder doesn't miscompile this, and that the Analysis folder does fold it. llvm-svn: 94750
* Remove SCEVAllocSizeExpr and SCEVFieldOffsetExpr, and in their placeDan Gohman2010-01-281-2/+31
| | | | | | | | | | | | | | | | use plain SCEVUnknowns with ConstantExpr::getSizeOf and ConstantExpr::getOffsetOf constants. This eliminates a bunch of special-case code. Also add code for pattern-matching these expressions, for clients that want to recognize them. Move ScalarEvolution's logic for expanding array and vector sizeof expressions into an element count times the element size, to expose the multiplication to subsequent folding, into the regular constant folder. llvm-svn: 94737
* Fix a crasher trying to fold each element in a comparison between two vectorsNick Lewycky2010-01-211-2/+3
| | | | | | | | | | if one of the vectors didn't have elements (such as undef). Fixes PR 6096. Fix an issue in the constant folder where fcmp (<2 x %ty>, <2 x %ty>) would have <2 x i1> type if constant folding was successful and i1 type if it wasn't. This exposed a related issue in the bitcode reader. llvm-svn: 94069
* Move remaining stuff to the isInteger predicate.Benjamin Kramer2010-01-051-4/+4
| | | | llvm-svn: 92771
* Convert a ton of simple integer type equality tests to the new predicate.Benjamin Kramer2010-01-051-2/+2
| | | | llvm-svn: 92760
* Aggressively flip compare constant expressions where appropriate; constantEli Friedman2009-12-171-3/+5
| | | | | | folding in particular expects null to be on the RHS. llvm-svn: 91587
* Previously, all operands to Constant were themselves constant.Chris Lattner2009-10-281-16/+23
| | | | | | | | | In the new world order, BlockAddress can have a BasicBlock operand. This doesn't permute much, because if you have a ConstantExpr (or anything more specific than Constant) we still know the operand has to be a Constant. llvm-svn: 85375
* Teach vm core to more aggressively fold 'trunc' constantexprs,Chris Lattner2009-10-171-9/+160
| | | | | | | | | allowing it to simplify the crazy constantexprs in the testcases down to something sensible. This allows -std-compile-opts to completely "devirtualize" the pointers to member functions in the testcase from PR5176. llvm-svn: 84368
* strength reduce a ton of type equality tests to check the typeid (ThroughChris Lattner2009-10-051-9/+10
| | | | | | | | the new predicates I added) instead of going through a context and doing a pointer comparison. Besides being cheaper, this allows a smart compiler to turn the if sequence into a switch. llvm-svn: 83297
* Peer through zext and sext to eliminate them when it is safe to do so.Nick Lewycky2009-09-201-0/+16
| | | | llvm-svn: 82389
* Fold 'icmp eq (icmp), true' into an xor(icmp).Nick Lewycky2009-09-201-0/+14
| | | | llvm-svn: 82386
* Correct the comment; this applies to fcmp too.Nick Lewycky2009-09-201-1/+1
| | | | llvm-svn: 82380
* Remove tab, again.Nick Lewycky2009-09-201-1/+1
| | | | llvm-svn: 82379
* Teach the constant folder how to not a cmpinst.Nick Lewycky2009-09-201-0/+14
| | | | llvm-svn: 82378
* Try turning icmp(bitcast(x), bitcast(y)) into icmp(bitcast(bitcast(x)), y) inNick Lewycky2009-09-201-0/+10
| | | | | | the hopes that the two bitcasts will merge. llvm-svn: 82371
* Remove tabs I added.Nick Lewycky2009-09-201-8/+8
| | | | llvm-svn: 82369
* Clean up the usage of evaluateICmpRelation's return value.Nick Lewycky2009-09-201-37/+30
| | | | | | | Add another line to the ConstantExprFold test to demonstrate the GEPs may not wrap around in either the signed or unsigned senses. llvm-svn: 82361
* Remove dead store by taking a guess at what Chris meant. I wasn't able toNick Lewycky2009-09-201-2/+1
| | | | | | design a testcase that would tickle this behaviour. llvm-svn: 82357
* Delete dead code. sext and zext can not turn integers into pointers. Further,Nick Lewycky2009-09-201-15/+0
| | | | | | the optimization described in the comment is only valid with target data. llvm-svn: 82353
* Value* were never meant to be const. Removing constness from the constantNick Lewycky2009-09-201-163/+132
| | | | | | | folder removes a lot of const_casting and requires no changes to clang or llvm-gcc. llvm-svn: 82349
* Teach the constant folder how to handle a few simple i1 cases.Nick Lewycky2009-09-201-0/+31
| | | | llvm-svn: 82340
* Fix an accidental inversion of the inbounds flag.Dan Gohman2009-09-151-3/+3
| | | | llvm-svn: 81862
* fix PR4963: folding insertvalue would sometimes turn a packed struct intoChris Lattner2009-09-151-20/+24
| | | | | | an unpacked one. llvm-svn: 81845
* Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword andDan Gohman2009-09-111-7/+100
| | | | | | | | | | | | | how to fold notionally-out-of-bounds array getelementptr indices instead of just doing these in lib/Analysis/ConstantFolding.cpp, because it can be done in a fairly general way without TargetData, and because not all constants are visited by lib/Analysis/ConstantFolding.cpp. This enables more constant folding. Also, set the "inbounds" flag when the getelementptr indices are one-past-the-end. llvm-svn: 81483
* Factor out the code for checking that all indices in a getelementptr areDan Gohman2009-09-101-0/+8
| | | | | | | | | within the notional bounds of the static type of the getelementptr (which is not the same as "inbounds") from GlobalOpt into a utility routine, and use it in ConstantFold.cpp to check whether there are any mis-behaved indices. llvm-svn: 81478
* Revert 80959. It isn't sufficient to solve the full problem. And itDan Gohman2009-09-031-1/+3
| | | | | | introduced regressions in the Ocaml bindings tests. llvm-svn: 80969
* Remove the API for creating ConstantExprs with the nsw, nuw, inbounds,Dan Gohman2009-09-031-3/+1
| | | | | | | | | | | | | | | and exact flags. Because ConstantExprs are uniqued, creating an expression with this flag causes all expressions with the same operands to have the same flag, which may not be safe. Add, sub, mul, and sdiv ConstantExprs are usually folded anyway, so the main interesting flag here is inbounds, and the constant folder already knows how to set the inbounds flag automatically in most cases, so there isn't an urgent need for the API support. This can be reconsidered in the future, but for now just removing these API bits eliminates a source of potential trouble with little downside. llvm-svn: 80959
* Cleanup whitespace and indentation.Dan Gohman2009-08-291-29/+28
| | | | llvm-svn: 80451
* Push LLVMContexts through the IntegerType APIs.Owen Anderson2009-08-131-46/+46
| | | | llvm-svn: 78948
* Simplify this code, and use an in-bounds GEP.Dan Gohman2009-08-121-5/+7
| | | | llvm-svn: 78755
* Privatize the StructType table, which unfortunately involves routing ↵Owen Anderson2009-08-051-3/+3
| | | | | | contexts through a number of APIs. llvm-svn: 78258
* Move a few more APIs back to 2.5 forms. The only remaining ones left to ↵Owen Anderson2009-07-311-58/+58
| | | | | | | | change back are metadata related, which I'm waiting on to avoid conflicting with Devang. llvm-svn: 77721
* Move getTrue() and getFalse() to 2.5-like APIs.Owen Anderson2009-07-311-6/+6
| | | | llvm-svn: 77685
* Move more code back to 2.5 APIs.Owen Anderson2009-07-301-23/+23
| | | | llvm-svn: 77635
* Move types back to the 2.5 API.Owen Anderson2009-07-291-3/+3
| | | | llvm-svn: 77516
* Move ConstantExpr to 2.5 API.Owen Anderson2009-07-291-44/+44
| | | | llvm-svn: 77494
* Return ConstantVector to 2.5 API.Owen Anderson2009-07-281-26/+26
| | | | llvm-svn: 77366
* Change ConstantArray to 2.5 API.Owen Anderson2009-07-281-3/+3
| | | | llvm-svn: 77347
* Move ConstantStruct back to 2.5 API.Owen Anderson2009-07-271-3/+3
| | | | llvm-svn: 77266
OpenPOWER on IntegriCloud