summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Move ConstantFP construction back to the 2.5-ish API.Owen Anderson2009-07-271-8/+8
| | | | llvm-svn: 77247
* Revert the ConstantInt constructors back to their 2.5 forms where possible, ↵Owen Anderson2009-07-241-45/+45
| | | | | | thanks to contexts-on-types. More to come. llvm-svn: 77011
* Rename getConstantInt{True|False} to get{True|False} at Chris' behest.Owen Anderson2009-07-211-6/+6
| | | | llvm-svn: 76598
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-5/+5
| | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). llvm-svn: 75640
* Inline EvalVectorOp in order to get rid of passing-pointer-to-static-methods ↵Owen Anderson2009-07-131-38/+132
| | | | | | behavior. llvm-svn: 75538
* Begin the painful process of tearing apart the rat'ss nest that is ↵Owen Anderson2009-07-131-206/+239
| | | | | | | | | Constants.cpp and ConstantFold.cpp. This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's the only way I could figure out to make this process vaguely incremental. llvm-svn: 75445
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-5/+6
| | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. llvm-svn: 75379
* Remove the vicmp and vfcmp instructions. Because we never had a release withNick Lewycky2009-07-081-68/+22
| | | | | | | these instructions, no autoupgrade or backwards compatibility support is provided. llvm-svn: 74991
* Expand this test to handle more cases (remainder and shifts) of zero.Nick Lewycky2009-06-211-8/+15
| | | | llvm-svn: 73839
* implement PR4424: 0/x is always 0 for integer division.Chris Lattner2009-06-211-0/+7
| | | | llvm-svn: 73835
* Revert r73790, and replace it with a significantly less ugly solution. ↵Owen Anderson2009-06-201-60/+51
| | | | | | | | | Rather than trying to make the global reader-writer lock work, create separate recursive mutexes for each value map. The recursive-ness fixes the double-acquiring issue, which having one per ValueMap lets us continue to maintain some concurrency. llvm-svn: 73801
* Fix a serious bug that would cause deadlock during abstract type refinement. ↵Owen Anderson2009-06-191-51/+60
| | | | | | | | | | The constant creation gets involved, and we end up trying to recursively acquire a writer lock. The fix for this is slightly horrible, and involves passing a boolean "locked" parameter around in Constants.cpp, but it's better than having locked and unlocked versions of most of the code. llvm-svn: 73790
* Support vector casts in more places, fixing a variety of assertionDan Gohman2009-06-151-16/+16
| | | | | | | | | | | | | | | failures. To support this, add some utility functions to Type to help support vector/scalar-independent code. Change ConstantInt::get and ConstantFP::get to support vector types, and add an overload to ConstantInt::get that uses a static IntegerType type, for convenience. Introduce a new getConstant method for ScalarEvolution, to simplify common use cases. llvm-svn: 73431
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-041-8/+15
| | | | | | | | | | | | | | | 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
* Apply a patch by Micah Villmow to fix AsmParser to accept vectorDan Gohman2009-03-141-0/+6
| | | | | | | shift constant expressions, and add support for folding vector shift constant expressions. This fixes PR3802. llvm-svn: 67010
* Extension of GEP in constant folder was broken (apparently this codeDaniel Dunbar2009-02-241-1/+1
| | | | | | | has never been run!). - Sorry, don't know how to make an LLVM test case for this. llvm-svn: 65383
OpenPOWER on IntegriCloud