summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* fix PR8867: a crash handling fp128. Thanks to Nick for the testcase.Chris Lattner2010-12-291-1/+1
| | | | llvm-svn: 122613
* There is no need for isAssociative to take the type as an argument anymore.Duncan Sands2010-12-201-2/+1
| | | | llvm-svn: 122242
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-10/+7
| | | | | | | | 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
* Remove unneeded zero arrays.Benjamin Kramer2010-12-041-3/+1
| | | | llvm-svn: 120910
* remove unions from LLVM IR. They are severely buggy and notChris Lattner2010-08-281-40/+0
| | | | | | being actively maintained, improved, or extended. llvm-svn: 112356
* Constant fold x == undef to undef.Dan Gohman2010-06-281-1/+8
| | | | llvm-svn: 107074
* Use A.append(...) instead of A.insert(A.end(), ...) when A is aDan Gohman2010-06-211-1/+1
| | | | | | SmallVector, and other SmallVector simplifications. llvm-svn: 106452
* getFoldedOffsetOf no longer does anything special with vector types.Dan Gohman2010-06-051-1/+1
| | | | llvm-svn: 105514
* Make the 'icmp pred trunc(ext(X)), CST --> icmp pred X, ext(trunc(CST))'Nick Lewycky2010-03-041-24/+5
| | | | | | | | | | transformation much more careful. Truncating binary '01' to '1' sounds like it's safe until you realize that it switched from positive to negative under a signed interpretation, and that depends on the icmp predicate. Also a few miscellaneous cleanups. llvm-svn: 97721
* fix incorrect folding of icmp with undef, PR6481.Chris Lattner2010-03-031-1/+1
| | | | llvm-svn: 97659
* Teach the constant folder about union types.Dan Gohman2010-02-251-0/+34
| | | | llvm-svn: 97142
* Remove code which assumes it knows how vectors are stored in memory.Dan Gohman2010-02-251-12/+2
| | | | llvm-svn: 97141
* Canonicalize ConstantInts to the right operand of commutativeDan Gohman2010-02-221-0/+4
| | | | | | | | | | operators. The test difference is just due to the multiplication operands being commuted (and thus requiring a more elaborate match). In optimized code, that expression would be folded. llvm-svn: 96816
* Use Instruction::isCommutative instead of duplicating it.Dan Gohman2010-02-221-24/+1
| | | | llvm-svn: 96807
* 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
OpenPOWER on IntegriCloud