summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* This is the patch to provide clean intrinsic function overloading support in ↵Chandler Carruth2007-08-041-3/+3
| | | | | | | | LLVM. It cleans up the intrinsic definitions and generally smooths the process for more complicated intrinsic writing. It will be used by the upcoming atomic intrinsics as well as vector and float intrinsics in the future. This also changes the syntax for llvm.bswap, llvm.part.set, llvm.part.select, and llvm.ct* intrinsics. They are automatically upgraded by both the LLVM ASM reader and the bitcode reader. The test cases have been updated, with special tests added to ensure the automatic upgrading is supported. llvm-svn: 40807
* Use ConstantFoldFP for folding all unary floating-point operations which mayDan Gohman2007-07-161-20/+25
| | | | | | | | | have an error, and refector out the code for binary operators into ConstantFoldBinaryFP and use it for all binary floating-point operations which may have an error. These functions still rely exclusively on errno to detect errors though. llvm-svn: 39923
* The bit counting intrinsics return i32 not the operand type. This fixesReid Spencer2007-04-011-4/+3
| | | | | | last night's regression in SingleSource/UnitTests/2005-05-11-Popcount-ffs-fls llvm-svn: 35556
* For PR1297:Reid Spencer2007-04-011-23/+17
| | | | | | Support overloaded intrinsics bswap, ctpop, cttz, ctlz. llvm-svn: 35547
* Unbreak VC++ build.Jeff Cohen2007-03-051-2/+2
| | | | llvm-svn: 34917
* For PR1195:Reid Spencer2007-02-151-2/+2
| | | | | | | Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and PackedTyID -> VectorTyID. No functional changes. llvm-svn: 34293
* completely eliminate a temporary vectorChris Lattner2007-02-101-2/+2
| | | | llvm-svn: 34162
* Privatize StructLayout::MemberOffsets, adding an accessorChris Lattner2007-02-101-1/+1
| | | | llvm-svn: 34156
* Changes to support making the shift instructions be true BinaryOperators.Reid Spencer2007-02-021-4/+0
| | | | | | | | | | | | This feature is needed in order to support shifts of more than 255 bits on large integer types. This changes the syntax for llvm assembly to make shl, ashr and lshr instructions look like a binary operator: shl i32 %X, 1 instead of shl i32 %X, i8 1 Additionally, this should help a few passes perform additional optimizations. llvm-svn: 33776
* Fix a minor bug in my patch yesterday that broken ConstProp/bswap.llChris Lattner2007-01-311-1/+1
| | | | llvm-svn: 33704
* elimiante a temporary vectorChris Lattner2007-01-311-3/+1
| | | | llvm-svn: 33694
* Move some symbolic constant folding code out of instcombine into a placeChris Lattner2007-01-311-3/+136
| | | | | | | it can be used by multiple clients. This specifically allows the inliner to constant fold symbolically. llvm-svn: 33687
* move a bunch of constant folding code f rom Transforms/Utils/Local.cpp intoChris Lattner2007-01-301-2/+155
| | | | | | libanalysis/ConstantFolding.cpp. llvm-svn: 33679
* adjust to constant folding api changes.Chris Lattner2007-01-301-5/+6
| | | | llvm-svn: 33673
* Constant fold llvm.powi.*. This speeds up tramp3d--v4 by 9.5%Chris Lattner2007-01-151-1/+12
| | | | llvm-svn: 33229
* remove llvm.isunorderedChris Lattner2007-01-071-5/+0
| | | | llvm-svn: 32991
* For PR950:Reid Spencer2006-12-311-1/+0
| | | | | | | | | | | | | This patch replaces signed integer types with signless ones: 1. [US]Byte -> Int8 2. [U]Short -> Int16 3. [U]Int -> Int32 4. [U]Long -> Int64. 5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion and other methods related to signedness. In a few places this warranted identifying the signedness information from other sources. llvm-svn: 32785
* Unbreak VC++ build.Jeff Cohen2006-12-021-0/+1
| | | | llvm-svn: 32113
* Remove redundant <cmath>.Jim Laskey2006-11-081-1/+0
| | | | llvm-svn: 31561
* For PR950:Reid Spencer2006-10-201-5/+6
| | | | | | | | This patch implements the first increment for the Signless Types feature. All changes pertain to removing the ConstantSInt and ConstantUInt classes in favor of just using ConstantInt. llvm-svn: 31063
* Constant fold sqrtfChris Lattner2006-06-171-1/+4
| | | | llvm-svn: 28853
* For PR411:Reid Spencer2006-01-161-7/+18
| | | | | | | | | | | | | | | | This patch is an incremental step towards supporting a flat symbol table. It de-overloads the intrinsic functions by providing type-specific intrinsics and arranging for automatically upgrading from the old overloaded name to the new non-overloaded name. Specifically: llvm.isunordered -> llvm.isunordered.f32, llvm.isunordered.f64 llvm.sqrt -> llvm.sqrt.f32, llvm.sqrt.f64 llvm.ctpop -> llvm.ctpop.i8, llvm.ctpop.i16, llvm.ctpop.i32, llvm.ctpop.i64 llvm.ctlz -> llvm.ctlz.i8, llvm.ctlz.i16, llvm.ctlz.i32, llvm.ctlz.i64 llvm.cttz -> llvm.cttz.i8, llvm.cttz.i16, llvm.cttz.i32, llvm.cttz.i64 New code should not use the overloaded intrinsic names. Warnings will be emitted if they are used. llvm-svn: 25366
* Add bswap intrinsics as documented in the Language ReferenceNate Begeman2006-01-141-0/+15
| | | | llvm-svn: 25309
* Move some constant folding functions into LLVMAnalysis since they are usedJohn Criswell2005-10-271-0/+172
by Analysis and Transformation passes. llvm-svn: 24038
OpenPOWER on IntegriCloud