summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Switch llvm.cttz and llvm.ctlz to accept a second i1 parameter whichChandler Carruth2011-12-121-4/+8
| | | | | | | | | | | | | | | | | | | | indicates whether the intrinsic has a defined result for a first argument equal to zero. This will eventually allow these intrinsics to accurately model the semantics of GCC's __builtin_ctz and __builtin_clz and the X86 instructions (prior to AVX) which implement them. This patch merely sets the stage by extending the signature of these intrinsics and establishing auto-upgrade logic so that the old spelling still works both in IR and in bitcode. The upgrade logic preserves the existing (inefficient) semantics. This patch should not change any behavior. CodeGen isn't updated because it can use the existing semantics regardless of the flag's value. Note that this will be followed by API updates to Clang and DragonEgg. Reviewed by Nick Lewycky! llvm-svn: 146357
* Add support for vectors of pointers.Nadav Rotem2011-12-051-1/+2
| | | | llvm-svn: 145801
* Add support for constant folding the pow intrinsic.Chad Rosier2011-12-031-3/+6
| | | | | | rdar://10514247 llvm-svn: 145730
* Abuse of mass replace isn't warranted even when the build is failing. ThanksChad Rosier2011-12-011-25/+29
| | | | | | for the suggestion, Eric. llvm-svn: 145643
* Fix build by not assuming TLI is guaranteed. Will have to track down cases whereChad Rosier2011-12-011-24/+23
| | | | | | TLI isn't being passed to ensure we don't miss opportunities to fold calls. llvm-svn: 145641
* Prevent library calls from being folded if -fno-builtin has been specified.Chad Rosier2011-12-011-23/+24
| | | | | | rdar://10500969 llvm-svn: 145639
* Propagate TargetLibraryInfo throughout ConstantFolding.cpp and Chad Rosier2011-12-011-26/+35
| | | | | | | InstructionSimplify.cpp. Other fixups as needed. Part of rdar://10500969 llvm-svn: 145559
* Fixes following the CR by Chris and Duncan:Nadav Rotem2011-08-291-6/+0
| | | | | | | Optimize chained bitcasts of the form A->B->A. Undo r138722 and change isEliminableCastPair to allow this case. llvm-svn: 138756
* Bitcasts are transitive. Bitcast-Bitcast-X becomes Bitcast-X.Nadav Rotem2011-08-281-0/+6
| | | | llvm-svn: 138722
* Implement Constant::isAllOnesValue(). Fix ConstantFolding to use the new api.Nadav Rotem2011-08-241-10/+7
| | | | llvm-svn: 138469
* Revert "Address Duncan's CR request:"Eric Christopher2011-08-231-4/+9
| | | | | | | | | | This reverts commit 20a05be15ea5271ab6185b83200fa88263362400. (svn rev 138340) Conflicts: test/Transforms/InstCombine/bitcast.ll llvm-svn: 138366
* Address Duncan's CR request:Nadav Rotem2011-08-231-9/+4
| | | | | | | 1. Cleanup the tests in ConstantFolding.cpp 2. Implement isAllOnes for Constant, ConstantFP, ConstantVector llvm-svn: 138340
* Add constant folding support for bitcasts of splat vectors to integers.Nadav Rotem2011-08-201-2/+10
| | | | llvm-svn: 138206
* Convert GetElementPtrInst to use ArrayRef.Jay Foad2011-07-251-2/+1
| | | | llvm-svn: 135904
* Convert ConstantExpr::getGetElementPtr andJay Foad2011-07-211-4/+3
| | | | | | ConstantExpr::getInBoundsGetElementPtr to use ArrayRef. llvm-svn: 135673
* Convert TargetData::getIndexedOffset to use ArrayRef.Jay Foad2011-07-191-7/+5
| | | | llvm-svn: 135478
* Use ArrayRef in ConstantFoldInstOperands and ConstantFoldCall.Jay Foad2011-07-191-22/+21
| | | | llvm-svn: 135477
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-31/+31
| | | | llvm-svn: 135375
* Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.Jay Foad2011-07-131-2/+2
| | | | llvm-svn: 135040
* Revert "revert 133714"Rafael Espindola2011-06-231-2/+1
| | | | | | | | This reverts commit e8e00f5efb4a22238f2407bf813de4606f30c5aa. The cmake build on OS X is still broken. llvm-svn: 133718
* revert 133714Dylan Noblesmith2011-06-231-1/+2
| | | | | | It broke the build worse. llvm-svn: 133716
* 133713 broke the build, revert it.Rafael Espindola2011-06-231-2/+1
| | | | llvm-svn: 133714
* Support: make floating-exception header privateDylan Noblesmith2011-06-231-1/+2
| | | | | | | | 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. llvm-svn: 133713
* Revamp the "ConstantStruct::get" methods. Previously, these were scatteredChris Lattner2011-06-201-1/+1
| | | | | | | | | | | | | | | 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. llvm-svn: 133412
* implement PR9315, constant folding exp2 in terms of pow (since hosts withoutChris Lattner2011-05-221-1/+7
| | | | | | C99 runtimes don't have exp2). llvm-svn: 131872
* Don't include Operator.h from InstrTypes.h.Jay Foad2011-04-111-0/+1
| | | | llvm-svn: 129271
* Constant folding support for calls to umul.with.overflow(), basically ↵Frits van Bommel2011-03-271-3/+8
| | | | | | identical to the smul.with.overflow() code. llvm-svn: 128379
* convert ConstantVector::get to use ArrayRef.Chris Lattner2011-02-151-2/+2
| | | | llvm-svn: 125537
* revert my ConstantVector patch, it seems to have made the llvm-gccChris Lattner2011-02-141-2/+2
| | | | | | builders unhappy. llvm-svn: 125504
* Switch ConstantVector::get to use ArrayRef instead of a pointer+sizeChris Lattner2011-02-141-2/+2
| | | | | | idiom. Change various clients to simplify their code. llvm-svn: 125487
* Simplify test, as suggested by Chris.Anders Carlsson2011-02-061-6/+2
| | | | llvm-svn: 124990
* When loading from a constant, fold inttoptr if the integer type and the ↵Anders Carlsson2011-02-061-0/+11
| | | | | | resulting pointer type both have the same size. llvm-svn: 124987
* Give GetUnderlyingObject a TargetData, to keep it in syncDan Gohman2011-01-241-1/+2
| | | | | | | | | | | 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. llvm-svn: 124134
* fix PR8983, a broken assertion.Chris Lattner2011-01-161-1/+1
| | | | llvm-svn: 123562
* Teach constant folding to perform conversions from constant floatingChandler Carruth2011-01-111-0/+56
| | | | | | | | 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. llvm-svn: 123206
* Cleanup some of the constant folding code to consistently test intrinsicChandler Carruth2011-01-101-16/+18
| | | | | | | IDs when available rather than using a mixture of IDs and textual name comparisons. llvm-svn: 123165
* use isNullValue() to simplify code, add an assert.Chris Lattner2011-01-061-5/+6
| | | | llvm-svn: 122977
* implement constant folding support for an exotic constant expr:Chris Lattner2011-01-061-1/+19
| | | | | | | | | | 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. llvm-svn: 122950
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-2/+1
| | | | | | | new gcc warning that complains on self-assignments and self-initializations. llvm-svn: 122458
* Move Value::getUnderlyingObject to be a standaloneDan Gohman2010-12-151-1/+1
| | | | | | | function so that it can live in Analysis instead of VMCore. llvm-svn: 121885
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-4/+2
| | | | | | | | 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. llvm-svn: 121120
* Teach ConstantFoldInstruction() how to fold insertvalue and extractvalue.Frits van Bommel2010-11-291-1/+12
| | | | llvm-svn: 120316
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120298
* Clarify that constant folding of instructions applies when all operandsDuncan Sands2010-11-231-10/+11
| | | | | | | | 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). llvm-svn: 120015
* Fix spelling.Duncan Sands2010-11-211-2/+2
| | | | llvm-svn: 119941
* apply Dan's fix for PR8268 which allows constant folding to handle indexes overChris Lattner2010-11-211-7/+15
| | | | | | | | | | | zero sized elements. This allows us to compile: #include <string> void foo() { std::string s; } into an empty function. llvm-svn: 119933
* Boost the power of phi node constant folding slightly: if allDuncan Sands2010-11-141-12/+18
| | | | | | | | | | | 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. llvm-svn: 119041
* add uadd_ov/usub_ov to apint, consolidate constant foldingChris Lattner2010-10-141-32/+28
| | | | | | | | | 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. llvm-svn: 116457
* Don't try to constant fold libm functions with non-finite arguments.Jakob Stoklund Olesen2010-09-271-0/+7
| | | | | | | | 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. llvm-svn: 114893
* Don't include <fenv.h> now that we have llvm/System/FEnv.h.Jakob Stoklund Olesen2010-09-171-1/+0
| | | | llvm-svn: 114219
OpenPOWER on IntegriCloud