summaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
Commit message (Collapse)AuthorAge
* Add a comment to explain a folding transform.Reid Spencer2007-03-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35360 91177308-0d34-0410-b5e6-96231b3b80d8
* fold constantexprs more aggressively, fixing PR1265Chris Lattner2007-03-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35336 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix constant fold of div by zero and rem by zero to match IEEE 754Reid Spencer2007-03-23
| | | | | | | | requirements. We must return NaN in some cases and correctly signed infinity in other cases. Passes CFP2006 (not that that says much). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35277 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix constant folding of fp->int bitcast for vectors.Reid Spencer2007-03-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34880 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefer non-virtual calls to ConstantInt::isZero over virtual calls toReid Spencer2007-03-02
| | | | | | | Constant::isNullValue() in situations where it is possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34821 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the APInt versions of the bit-wise conversions of float/double to intReid Spencer2007-03-01
| | | | | | | | | and back. While this is not strictly necessary, it does pave the way for future changes in casting. It should now be possible to improve vector casting to deal with un-equal fp/int sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34808 91177308-0d34-0410-b5e6-96231b3b80d8
* Use a simpler constructor when constructing ConstantInst.Reid Spencer2007-03-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34793 91177308-0d34-0410-b5e6-96231b3b80d8
* Pull out the stops.Reid Spencer2007-02-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34703 91177308-0d34-0410-b5e6-96231b3b80d8
* Adjust to changes in the APInt interface.Reid Spencer2007-02-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34681 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1205:Reid Spencer2007-02-27
| | | | | | | | | | | | Implement review feedback: 1. Use new APInt::RoundDoubleToAPInt interface to specify the bit width so that we don't have to truncate or extend in constant folding. 2. Fix a pasteo in SDiv that prevented a check for overflow. 3. Fix the shift operators: undef happens when the shift amount is equal to the bitwidth. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34677 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1205:Reid Spencer2007-02-27
| | | | | | | Implement constant folding via APInt instead of uint64_t. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34660 91177308-0d34-0410-b5e6-96231b3b80d8
* ConstantFolding.cpp/h -> ConstantFold.cpp/h to avoid confusion withChris Lattner2007-02-27
| | | | | | | lib/Analysis/ConstantFolding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34653 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Transforms/ConstProp/2007-02-23-sdiv.ll and PR1215Chris Lattner2007-02-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34548 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1195:Reid Spencer2007-02-15
| | | | | | | | Change use of "packed" term to "vector" in comments, strings, variable names, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34300 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1195:Reid Spencer2007-02-15
| | | | | | | | Rename PackedType -> VectorType, ConstantPacked -> ConstantVector, and PackedTyID -> VectorTyID. No functional changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34293 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix Transforms/ConstProp/2007-02-05-BitCast.llChris Lattner2007-02-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33948 91177308-0d34-0410-b5e6-96231b3b80d8
* Revise APIs for creating constantexpr GEPs to not require the use of vectors.Chris Lattner2007-01-31
| | | | | | | This allows us to eliminate many temporary vectors, and theirassociated malloc/free pairs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33692 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1043:Reid Spencer2007-01-19
| | | | | | | | | | | | | | | This is the final patch for this PR. It implements some minor cleanup in the use of IntegerType, to wit: 1. Type::getIntegerTypeMask -> IntegerType::getBitMask 2. Type::Int*Ty changed to IntegerType* from Type* 3. ConstantInt::getType() returns IntegerType* now, not Type* This also fixes PR1120. Patch by Sheng Zhou. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33370 91177308-0d34-0410-b5e6-96231b3b80d8
* rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.Chris Lattner2007-01-15
| | | | | | | | | | rename Type::getIntegralTypeMask to Type::getIntegerTypeMask. This makes naming much more consistent. For example, there are now no longer any instances of IntegerType that are not considered isInteger! :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33225 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a bunch of duplicated code. Among other things, this fixesChris Lattner2007-01-12
| | | | | | | constant folding of signed comparisons of bool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33134 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1064:Reid Spencer2007-01-12
| | | | | | | | | | | | | | | | | | | | | | | | Implement the arbitrary bit-width integer feature. The feature allows integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 16, 32, and 64 bit integers. This change does several things: 1. Introduces a new Derived Type, IntegerType, to represent the number of bits in an integer. The Type classes SubclassData field is used to store the number of bits. This allows 2^23 bits in an integer type. 2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and 64-bit integers. These are replaced with just IntegerType which is not a primitive any more. 3. Adjust the rest of LLVM to account for this change. Note that while this incremental change lays the foundation for arbitrary bit-width integers, LLVM has not yet been converted to actually deal with them in any significant way. Most optimization passes, for example, will still only deal with the byte-width integer types. Future increments will rectify this situation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement review feedback for the ConstantBool->ConstantInt merge. ChrisReid Spencer2007-01-12
| | | | | | | | | recommended that getBoolValue be replaced with getZExtValue and that get(bool) be replaced by get(const Type*, uint64_t). This implements those changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33110 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename BoolTy as Int1Ty. Patch by Sheng Zhou.Reid Spencer2007-01-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33076 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR1043:Zhou Sheng2007-01-11
| | | | | | | | Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement better constant folding of unordered FCMP predicates.Reid Spencer2007-01-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33063 91177308-0d34-0410-b5e6-96231b3b80d8
* fix typoChris Lattner2007-01-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32859 91177308-0d34-0410-b5e6-96231b3b80d8
* fix some bugs handling vectors, avoid host-specific handling of undefined ↵Chris Lattner2007-01-04
| | | | | | shift results. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32857 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug in comparison of GEP indices.Reid Spencer2006-12-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32798 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR950:Reid Spencer2006-12-31
| | | | | | | Change signed integer type names to unsigned equivalents. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32780 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup ConstantFoldCompareInstruction:Reid Spencer2006-12-24
| | | | | | | | | | | 1. Make the arguments const like the other ConstantFold* functions. 2. Clean up evaluateFCmpRelation so it makes sense for floating point. 3. Implement the use of evaluateFCmpRelation to fold floating point CEs 4. Shorten a variable name so more things fit on one line. 5. Fix various comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32759 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't overload var names.Reid Spencer2006-12-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32752 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR950:Reid Spencer2006-12-23
| | | | | | | | | This patch removes the SetCC instructions and replaces them with the ICmp and FCmp instructions. The SetCondInst instruction has been removed and been replaced with ICmpInst and FCmpInst. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32751 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up ConstantFoldCastInstruction.Reid Spencer2006-12-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32672 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite ConstantFoldCastInstruction so that it doesn't use any of theReid Spencer2006-12-19
| | | | | | | | ConstRules. Remove the casting rules from ConstRules and subclasses. This cleans up ConstantFolding significantly. Passes all tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32671 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert last patch. ConstantInt isn't quite ready for signlessness.Reid Spencer2006-12-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32650 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the last use of getUnsignedVersion and getSignedVersion from VMCore.Reid Spencer2006-12-18
| | | | | | | | | ConstantInt doesn't care about the sign of the type it represents. It only cares about the bitwidth so there is no need to make the sign of the type match the SExt or ZExt constant expression. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32646 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace inferred getCast(V,Ty) calls with more strict variants.Reid Spencer2006-12-12
| | | | | | | | Rename getZeroExtend and getSignExtend to getZExt and getSExt to match the the casting mnemonics in the rest of LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32514 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix constant folding of FP->int due to cut & paste error in last commit.Reid Spencer2006-12-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32447 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement correct constant folding of bitcast. This implementsChris Lattner2006-12-11
| | | | | | | | Transforms/ConstProp/bitcast.ll and fixes SingleSource/Regression/C/2003-10-12-GlobalVarInitializers git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32438 91177308-0d34-0410-b5e6-96231b3b80d8
* fix typoChris Lattner2006-12-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32428 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix constant folding to deal with external weak global values.Reid Spencer2006-12-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32247 91177308-0d34-0410-b5e6-96231b3b80d8
* Can't make these fail now with just BitCast. Previous failures must haveReid Spencer2006-12-05
| | | | | | | | been in conjunction with something else. By right, they should just be BitCasts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32219 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the last inferred casts from VMCore.Reid Spencer2006-12-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32213 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR950: Implement a stub for folding ICmp and FCmp instructionsReid Spencer2006-12-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32169 91177308-0d34-0410-b5e6-96231b3b80d8
* Change inferred casts to explicit casts.Reid Spencer2006-12-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32165 91177308-0d34-0410-b5e6-96231b3b80d8
* These should be rewritten to fold without using the 'Rules' mechanism, butChris Lattner2006-12-01
| | | | | | | | until this happens at least make sext from bool and sitofp from bool do the right thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32087 91177308-0d34-0410-b5e6-96231b3b80d8
* this logic is broken for trunc to bool, replace the folding logic for truncChris Lattner2006-12-01
| | | | | | | | completely, as it is trivial. We should probably do this for the rest of the cast operations. This fixes ConstProp/2006-12-01-TruncBoolBug.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32081 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo introduced by the cast patch that horribly broke a lot of vectorChris Lattner2006-12-01
| | | | | | | code. Testcase here: Transforms/ConstProp/2006-11-30-vector-cast.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32062 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't fold "ptrtoint GV to bool" since this should be doing a truncate notReid Spencer2006-12-01
| | | | | | | | a comparison against zero. Instead fold setne(GV,null) and seteq(GV,null) to ConstantBool::True or ConstantBool::False, respectively. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32060 91177308-0d34-0410-b5e6-96231b3b80d8
* Introducing external weak linkage. Darwin codegen should be added later.Anton Korobeynikov2006-12-01
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32052 91177308-0d34-0410-b5e6-96231b3b80d8