summaryrefslogtreecommitdiff
path: root/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAge
* Fixes following the CR by Chris and Duncan:Nadav Rotem2011-08-29
| | | | | | | | | Optimize chained bitcasts of the form A->B->A. Undo r138722 and change isEliminableCastPair to allow this case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138756 91177308-0d34-0410-b5e6-96231b3b80d8
* Bitcasts are transitive. Bitcast-Bitcast-X becomes Bitcast-X.Nadav Rotem2011-08-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138722 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement Constant::isAllOnesValue(). Fix ConstantFolding to use the new api.Nadav Rotem2011-08-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138469 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Address Duncan's CR request:"Eric Christopher2011-08-23
| | | | | | | | | | This reverts commit 20a05be15ea5271ab6185b83200fa88263362400. (svn rev 138340) Conflicts: test/Transforms/InstCombine/bitcast.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138366 91177308-0d34-0410-b5e6-96231b3b80d8
* Address Duncan's CR request:Nadav Rotem2011-08-23
| | | | | | | | | | | 1. Cleanup the tests in ConstantFolding.cpp 2. Implement isAllOnes for Constant, ConstantFP, ConstantVector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138340 91177308-0d34-0410-b5e6-96231b3b80d8
* Add constant folding support for bitcasts of splat vectors to integers.Nadav Rotem2011-08-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138206 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135904 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-21
| | | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135673 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert TargetData::getIndexedOffset to use ArrayRef.Jay Foad2011-07-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135478 91177308-0d34-0410-b5e6-96231b3b80d8
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135477 91177308-0d34-0410-b5e6-96231b3b80d8
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.Jay Foad2011-07-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135040 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "revert 133714"Rafael Espindola2011-06-23
| | | | | | | | This reverts commit e8e00f5efb4a22238f2407bf813de4606f30c5aa. The cmake build on OS X is still broken. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133718 91177308-0d34-0410-b5e6-96231b3b80d8
* revert 133714Dylan Noblesmith2011-06-23
| | | | | | | | It broke the build worse. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133716 91177308-0d34-0410-b5e6-96231b3b80d8
* 133713 broke the build, revert it.Rafael Espindola2011-06-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133714 91177308-0d34-0410-b5e6-96231b3b80d8
* Support: make floating-exception header privateDylan Noblesmith2011-06-23
| | | | | | | | | | It has only one user. This eliminates the last include of config.h from the public headers -- ideally, config.h shouldn't even be installed by `make install` anymore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133713 91177308-0d34-0410-b5e6-96231b3b80d8
* Revamp the "ConstantStruct::get" methods. Previously, these were scatteredChris Lattner2011-06-20
| | | | | | | | | | | | | | | | | all over the place in different styles and variants. Standardize on two preferred entrypoints: one that takes a StructType and ArrayRef, and one that takes StructType and varargs. In cases where there isn't a struct type convenient, we now add a ConstantStruct::getAnon method (whose name will make more sense after a few more patches land). It would be "really really nice" if the ConstantStruct::get and ConstantVector::get methods didn't make temporary std::vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133412 91177308-0d34-0410-b5e6-96231b3b80d8
* implement PR9315, constant folding exp2 in terms of pow (since hosts withoutChris Lattner2011-05-22
| | | | | | | C99 runtimes don't have exp2). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131872 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129271 91177308-0d34-0410-b5e6-96231b3b80d8
* Constant folding support for calls to umul.with.overflow(), basically ↵Frits van Bommel2011-03-27
| | | | | | identical to the smul.with.overflow() code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128379 91177308-0d34-0410-b5e6-96231b3b80d8
* convert ConstantVector::get to use ArrayRef.Chris Lattner2011-02-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125537 91177308-0d34-0410-b5e6-96231b3b80d8
* revert my ConstantVector patch, it seems to have made the llvm-gccChris Lattner2011-02-14
| | | | | | | builders unhappy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125504 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch ConstantVector::get to use ArrayRef instead of a pointer+sizeChris Lattner2011-02-14
| | | | | | | idiom. Change various clients to simplify their code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125487 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify test, as suggested by Chris.Anders Carlsson2011-02-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124990 91177308-0d34-0410-b5e6-96231b3b80d8
* When loading from a constant, fold inttoptr if the integer type and the ↵Anders Carlsson2011-02-06
| | | | | | resulting pointer type both have the same size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124987 91177308-0d34-0410-b5e6-96231b3b80d8
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-24
| | | | | | | | | | | | with BasicAA's DecomposeGEPExpression, which recently began using a TargetData. This fixes PR8968, though the testcase is awkward to reduce. Also, update several off GetUnderlyingObject's users which happen to have a TargetData handy to pass it in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124134 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR8983, a broken assertion.Chris Lattner2011-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123562 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach constant folding to perform conversions from constant floatingChandler Carruth2011-01-11
| | | | | | | | point values to their integer representation through the SSE intrinsic calls. This is the last part of a README.txt entry for which I have real world examples. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123206 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup some of the constant folding code to consistently test intrinsicChandler Carruth2011-01-10
| | | | | | | IDs when available rather than using a mixture of IDs and textual name comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123165 91177308-0d34-0410-b5e6-96231b3b80d8
* use isNullValue() to simplify code, add an assert.Chris Lattner2011-01-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122977 91177308-0d34-0410-b5e6-96231b3b80d8
* implement constant folding support for an exotic constant expr:Chris Lattner2011-01-06
| | | | | | | | | | | | ret i64 ptrtoint (i8* getelementptr ([1000 x i8]* @X, i64 1, i64 sub (i64 0, i64 ptrtoint ([1000 x i8]* @X to i64))) to i64) to "ret i64 1000". This allows us to correctly compute the trip count on a loop in PR8883, which occurs with std::fill on a char array. This allows us to transform it into a memset with a constant size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122950 91177308-0d34-0410-b5e6-96231b3b80d8
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-23
| | | | | | | | | new gcc warning that complains on self-assignments and self-initializations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122458 91177308-0d34-0410-b5e6-96231b3b80d8
* Move Value::getUnderlyingObject to be a standaloneDan Gohman2010-12-15
| | | | | | | | function so that it can live in Analysis instead of VMCore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121885 91177308-0d34-0410-b5e6-96231b3b80d8
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-07
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.Frits van Bommel2010-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120316 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge System into Support.Michael J. Spencer2010-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
* Clarify that constant folding of instructions applies when all operandsDuncan Sands2010-11-23
| | | | | | | | | are constant. There was in fact one exception to this (phi nodes) - so remove that exception (InstructionSimplify handles this so there should be no loss). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120015 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix spelling.Duncan Sands2010-11-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119941 91177308-0d34-0410-b5e6-96231b3b80d8
* apply Dan's fix for PR8268 which allows constant folding to handle indexes overChris Lattner2010-11-21
| | | | | | | | | | | | | zero sized elements. This allows us to compile: #include <string> void foo() { std::string s; } into an empty function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119933 91177308-0d34-0410-b5e6-96231b3b80d8
* Boost the power of phi node constant folding slightly: if allDuncan Sands2010-11-14
| | | | | | | | | | | | operands are the phi node itself or undef, then return undef. This logic already existed at a higher level so in practice it shouldn't make the slightest difference. Note that this code could be replaced by a call to PN->hasConstantValue(). However since we bail out the moment we see a non-constant operand, it is more efficient to have a specialized version of that logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119041 91177308-0d34-0410-b5e6-96231b3b80d8
* add uadd_ov/usub_ov to apint, consolidate constant foldingChris Lattner2010-10-14
| | | | | | | | | | logic to use the new APInt methods. Among other things this implements rdar://8501501 - llvm.smul.with.overflow.i32 should constant fold which comes from "clang -ftrapv", originally brought to my attention from PR8221. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116457 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to constant fold libm functions with non-finite arguments.Jakob Stoklund Olesen2010-09-27
| | | | | | | | Usually we wouldn't do this anyway because llvm_fenv_testexcept would return an exception, but we have seen some cases where neither errno nor fenv detect an exception on arm-linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114893 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't include <fenv.h> now that we have llvm/System/FEnv.h.Jakob Stoklund Olesen2010-09-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114219 91177308-0d34-0410-b5e6-96231b3b80d8
* Attempt to support platforms which don't have fenv.h.Dan Gohman2010-09-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114196 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the folding of floating-point math library calls, like sin(infinity),Dan Gohman2010-09-17
| | | | | | | | so that it detects errors on platforms where libm doesn't set errno. It's still subject to host libm details though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114148 91177308-0d34-0410-b5e6-96231b3b80d8
* eliminate CallInst::ArgOffsetGabor Greif2010-07-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108522 91177308-0d34-0410-b5e6-96231b3b80d8
* Add parentheses around an || to correct the logic. Also silences a GCC warningChandler Carruth2010-07-12
| | | | | | | | | | that was actually useful here. Chris, please double check that this is the correct interpretation. I was pretty sure, and ran it by Nick as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108129 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR7429, a crash turning a load from a string into a float.Chris Lattner2010-07-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108113 91177308-0d34-0410-b5e6-96231b3b80d8
* conditionalize by CallInst::ArgOffsetGabor Greif2010-07-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107767 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate unnecessary uses of getZExtValue().Dan Gohman2010-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106279 91177308-0d34-0410-b5e6-96231b3b80d8