summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Push LLVMContexts through the IntegerType APIs.Owen Anderson2009-08-131-14/+17
| | | | llvm-svn: 78948
* Move a few more APIs back to 2.5 forms. The only remaining ones left to ↵Owen Anderson2009-07-311-9/+9
| | | | | | | | change back are metadata related, which I'm waiting on to avoid conflicting with Devang. llvm-svn: 77721
* Move more code back to 2.5 APIs.Owen Anderson2009-07-301-4/+4
| | | | llvm-svn: 77635
* Move types back to the 2.5 API.Owen Anderson2009-07-291-4/+4
| | | | llvm-svn: 77516
* Move ConstantExpr to 2.5 API.Owen Anderson2009-07-291-26/+26
| | | | llvm-svn: 77494
* Return ConstantVector to 2.5 API.Owen Anderson2009-07-281-1/+1
| | | | llvm-svn: 77366
* Move ConstantFP construction back to the 2.5-ish API.Owen Anderson2009-07-271-6/+6
| | | | llvm-svn: 77247
* Remove Value::getNameLenDaniel Dunbar2009-07-261-78/+44
| | | | llvm-svn: 77148
* Revert the ConstantInt constructors back to their 2.5 forms where possible, ↵Owen Anderson2009-07-241-10/+10
| | | | | | thanks to contexts-on-types. More to come. llvm-svn: 77011
* Get rid of the Pass+Context magic.Owen Anderson2009-07-221-71/+71
| | | | llvm-svn: 76702
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-141-3/+3
| | | | | | | | | 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
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-111-3/+4
| | | | | | | | | 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-2/+0
| | | | | | | these instructions, no autoupgrade or backwards compatibility support is provided. llvm-svn: 74991
* "LLVMContext* " --> "LLVMContext *"Owen Anderson2009-07-061-11/+11
| | | | llvm-svn: 74878
* Thread LLVMContext through the constant folding APIs, which touches a lot of ↵Owen Anderson2009-07-061-102/+120
| | | | | | files. llvm-svn: 74844
* Support vector casts in more places, fixing a variety of assertionDan Gohman2009-06-151-2/+2
| | | | | | | | | | | | | | | 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
* Change ConstantFoldConstantExpression to accept a nullDan Gohman2009-06-021-2/+0
| | | | | | | | | | | TargetData pointer. The only thing it's used for are calls to ConstantFoldCompareInstOperands and ConstantFoldInstOperands, which both already accept a null TargetData pointer. This makes ConstantFoldConstantExpression easier to use in clients where TargetData is optional. llvm-svn: 72741
* Use v.data() instead of &v[0] when SmallVector v might be empty.Jay Foad2009-05-211-5/+5
| | | | llvm-svn: 72210
* Rename PaddedSize to AllocSize, in the hope that thisDuncan Sands2009-05-091-3/+3
| | | | | | | will make it more obvious what it represents, and stop it being confused with the StoreSize. llvm-svn: 71349
* Revert 71165. It did more than just revert 71158 and it introducedDan Gohman2009-05-071-4/+36
| | | | | | several regressions. The problem due to 71158 is now fixed. llvm-svn: 71176
* Temporarily revert r71158. It was causing a failure during a full bootstrap:Bill Wendling2009-05-071-36/+4
| | | | | | | | | | | | | | | | | | | | | checking for bcopy... no checking for getc_unlocked... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511. /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decUtility.c:360: internal compiler error: Abort trap Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://developer.apple.com/bugreporter> for instructions. make[4]: *** [decUtility.o] Error 1 make[4]: *** Waiting for unfinished jobs.... Assertion failed: (0 && "Unknown SCEV kind!"), function operator(), file /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmCore.roots/llvmCore~obj/src/lib/Analysis/ScalarEvolution.cpp, line 511. /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvmgcc42.roots/llvmgcc42~obj/src/libdecnumber/decNumber.c:5591: internal compiler error: Abort trap Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://developer.apple.com/bugreporter> for instructions. make[4]: *** [decNumber.o] Error 1 make[3]: *** [all-stage2-libdecnumber] Error 2 make[3]: *** Waiting for unfinished jobs.... llvm-svn: 71165
* Constant-fold ptrtoint+add+inttoptr to gep when the pointer is anDan Gohman2009-05-071-4/+36
| | | | | | | array and the add is within range. This helps simplify expressions expanded by ScalarEvolutionExpander. llvm-svn: 71158
* use higher level APIs.Chris Lattner2009-04-031-8/+6
| | | | llvm-svn: 68351
* Rename getABITypeSize to getTypePaddedSize, asDuncan Sands2009-01-121-1/+1
| | | | | | suggested by Chris. llvm-svn: 62099
* Fix whitespace in comment.Nick Lewycky2008-12-151-2/+1
| | | | | | | Remove TODO; icmp isn't a binary operator, so this function will never deal with them. llvm-svn: 61020
* undef beats zero. Fix this missed optimization opportunity. Patch by Matt Elder!Nick Lewycky2008-11-201-1/+1
| | | | llvm-svn: 59705
* Don't try to create a mask when we don't need one. Fixes a crash.Nick Lewycky2008-10-241-4/+6
| | | | llvm-svn: 58075
* Teach constant folding that an inttoptr of aDuncan Sands2008-08-131-0/+13
| | | | | | | ptrtoint can be turned into a bitcast if the integer is at least as wide as a pointer. llvm-svn: 54752
* Fix minor issues with VICmp/VFCmp constant expressionsNate Begeman2008-07-251-1/+3
| | | | llvm-svn: 54030
* "ret (constexpr)" can't be folded into a Constant. Add a method toNick Lewycky2008-05-251-16/+45
| | | | | | | | | | Analysis/ConstantFolding to fold ConstantExpr's, then make instcombine use it to try to use targetdata to fold constant expressions on void instructions. Also extend the icmp(inttoptr, inttoptr) folding to handle the case where int size != ptr size. llvm-svn: 51559
* transform more loops to iterator form, detabifyGabor Greif2008-05-221-1/+1
| | | | llvm-svn: 51436
* Rewrite operand loops to use iterators. This shrinks .o file (at gcc4.0.1 ↵Gabor Greif2008-05-221-4/+5
| | | | | | -O3 x86) substantially (>500 bytes). Reason still unknown. llvm-svn: 51423
* suppress gcc3.4.6's <no value returned> warningsGabor Greif2008-05-211-0/+2
| | | | llvm-svn: 51372
* Remove dead return. Thanks to Bill for the review!Chris Lattner2008-05-081-2/+0
| | | | llvm-svn: 50863
* Add support for constant folding the 'offsetof' pattern even if theChris Lattner2008-05-081-16/+23
| | | | | | base is not zero. This fixes test/C++Frontend/2008-05-07-CrazyOffsetOf.cpp llvm-svn: 50840
* Switch to using Simplified ConstantFP::get API.Chris Lattner2008-04-201-11/+9
| | | | llvm-svn: 49977
* minor code cleanups, allow constant folding sinf/cosf.Chris Lattner2008-03-301-20/+26
| | | | llvm-svn: 48961
* Avoid unnecessarily casting away const, fixing a FIXME.Dan Gohman2008-01-311-1/+1
| | | | llvm-svn: 46591
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45418
* Fix a bug in my previous patch, thanks to Jay Foad forChris Lattner2007-12-121-2/+2
| | | | | | pointing this out and correcting the patch! llvm-svn: 44907
* Implement constant folding if vector<->vector bitcasts where the numberChris Lattner2007-12-111-2/+122
| | | | | | | of source/dest elements changes. This implements test/Transforms/InstCombine/bitcast-vector-fold.ll llvm-svn: 44855
* Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.Chris Lattner2007-12-101-19/+81
| | | | | | | | Reimplement the xform in Analysis/ConstantFolding.cpp where we can use targetdata to validate that it is safe. While I'm in there, fix some const correctness issues and generalize the interface to the "operand folder". llvm-svn: 44817
* splice some lines together, no functionality change.Chris Lattner2007-11-231-11/+7
| | | | llvm-svn: 44292
* Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.Duncan Sands2007-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The meaning of getTypeSize was not clear - clarifying it is important now that we have x86 long double and arbitrary precision integers. The issue with long double is that it requires 80 bits, and this is not a multiple of its alignment. This gives a primitive type for which getTypeSize differed from getABITypeSize. For arbitrary precision integers it is even worse: there is the minimum number of bits needed to hold the type (eg: 36 for an i36), the maximum number of bits that will be overwriten when storing the type (40 bits for i36) and the ABI size (i.e. the storage size rounded up to a multiple of the alignment; 64 bits for i36). This patch removes getTypeSize (not really - it is still there but deprecated to allow for a gradual transition). Instead there is: (1) getTypeSizeInBits - a number of bits that suffices to hold all values of the type. For a primitive type, this is the minimum number of bits. For an i36 this is 36 bits. For x86 long double it is 80. This corresponds to gcc's TYPE_PRECISION. (2) getTypeStoreSizeInBits - the maximum number of bits that is written when storing the type (or read when reading it). For an i36 this is 40 bits, for an x86 long double it is 80 bits. This is the size alias analysis is interested in (getTypeStoreSize returns the number of bytes). There doesn't seem to be anything corresponding to this in gcc. (3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded up to a multiple of the alignment. For an i36 this is 64, for an x86 long double this is 96 or 128 depending on the OS. This is the spacing between consecutive elements when you form an array out of this type (getABITypeSize returns the number of bytes). This is TYPE_SIZE in gcc. Since successive elements in a SequentialType (arrays, pointers and vectors) need to be aligned, the spacing between them will be given by getABITypeSize. This means that the size of an array is the length times the getABITypeSize. It also means that GEP computations need to use getABITypeSize when computing offsets. Furthermore, if an alloca allocates several elements at once then these too need to be aligned, so the size of the alloca has to be the number of elements multiplied by getABITypeSize. Logically speaking this doesn't have to be the case when allocating just one element, but it is simpler to also use getABITypeSize in this case. So alloca's and mallocs should use getABITypeSize. Finally, since gcc's only notion of size is that given by getABITypeSize, if you want to output assembler etc the same as gcc then getABITypeSize is the size you want. Since a store will overwrite no more than getTypeStoreSize bytes, and a read will read no more than that many bytes, this is the notion of size appropriate for alias analysis calculations. In this patch I have corrected all type size uses except some of those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard cases). I will get around to auditing these too at some point, but I could do with some help. Finally, I made one change which I think wise but others might consider pointless and suboptimal: in an unpacked struct the amount of space allocated for a field is now given by the ABI size rather than getTypeStoreSize. I did this because every other place that reserves memory for a type (eg: alloca) now uses getABITypeSize, and I didn't want to make an exception for unpacked structs, i.e. I did it to make things more uniform. This only effects structs containing long doubles and arbitrary precision integers. If someone wants to pack these types more tightly they can always use a packed struct. llvm-svn: 43620
* Rewrite sqrt and powi to use anyfloat. By popular demand.Dale Johannesen2007-10-021-12/+4
| | | | llvm-svn: 42537
* Add sqrt and powi intrinsics for long double.Dale Johannesen2007-09-281-0/+6
| | | | llvm-svn: 42423
* Next round of APFloat changes.Dale Johannesen2007-09-061-14/+41
| | | | | | | | | | | | | | Use APFloat in UpgradeParser and AsmParser. Change all references to ConstantFP to use the APFloat interface rather than double. Remove the ConstantFP double interfaces. Use APFloat functions for constant folding arithmetic and comparisons. (There are still way too many places APFloat is just a wrapper around host float/double, but we're getting there.) llvm-svn: 41747
* constant fold ptrtoint(inttoptr) with target data when available. This allowsChris Lattner2007-08-111-2/+17
| | | | | | | | | | us to fold the entry block of PR1602 to false instead of: br i1 icmp eq (i32 and (i32 ptrtoint (void (%struct.S*)* inttoptr (i64 1 to void (%struct.S*)*) to i32), i32 1), i32 0), label %cond_next, label %cond_true llvm-svn: 41023
* Handle functions with no name better.Chris Lattner2007-08-081-1/+2
| | | | llvm-svn: 40926
* significantly speed up constant folding of calls (and thus all clients that useChris Lattner2007-08-081-94/+131
| | | | | | | | ConstantFoldInstruction on calls) by avoiding Value::getName(). getName() constructs and returns an std::string, which does heap allocation stuff. This slightly speeds up instcombine. llvm-svn: 40924
OpenPOWER on IntegriCloud