summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Attempt to support platforms which don't have fenv.h.Dan Gohman2010-09-171-12/+7
| | | | llvm-svn: 114196
* Fix the folding of floating-point math library calls, like sin(infinity),Dan Gohman2010-09-171-2/+9
| | | | | | | so that it detects errors on platforms where libm doesn't set errno. It's still subject to host libm details though. llvm-svn: 114148
* eliminate CallInst::ArgOffsetGabor Greif2010-07-161-2/+2
| | | | llvm-svn: 108522
* Add parentheses around an || to correct the logic. Also silences a GCC warningChandler Carruth2010-07-121-1/+1
| | | | | | | | | 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. llvm-svn: 108129
* fix PR7429, a crash turning a load from a string into a float.Chris Lattner2010-07-121-3/+9
| | | | llvm-svn: 108113
* conditionalize by CallInst::ArgOffsetGabor Greif2010-07-071-2/+2
| | | | llvm-svn: 107767
* Eliminate unnecessary uses of getZExtValue().Dan Gohman2010-06-181-1/+1
| | | | llvm-svn: 106279
* Revert 101465, it broke internal OpenGL testing.Eric Christopher2010-04-161-2/+2
| | | | | | | Probably the best way to know that all getOperand() calls have been handled is to replace that API instead of updating. llvm-svn: 101579
* reapply r101434Gabor Greif2010-04-161-2/+2
| | | | | | | | | | | | | with a fix for self-hosting rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101465
* back out r101423 and r101397, they break llvm-gcc self-host on darwin10Gabor Greif2010-04-161-2/+2
| | | | llvm-svn: 101434
* reapply r101364, which has been backed out in r101368Gabor Greif2010-04-151-2/+2
| | | | | | | | | | | | | with a fix rotate CallInst operands, i.e. move callee to the back of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101397
* back out r101364, as it trips the linux nightlybot on some clang C++ testsGabor Greif2010-04-151-2/+2
| | | | llvm-svn: 101368
* rotate CallInst operands, i.e. move callee to the backGabor Greif2010-04-151-2/+2
| | | | | | | | | | of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary llvm-svn: 101364
* Minor code simplification.Dan Gohman2010-04-121-1/+1
| | | | llvm-svn: 101009
* FP16 constfoldingAnton Korobeynikov2010-03-191-0/+25
| | | | llvm-svn: 98911
* Simplify this code.Dan Gohman2010-03-181-16/+8
| | | | llvm-svn: 98853
* When constant folding GEP of GEP, do not crash if an index ofDuncan Sands2010-03-121-1/+13
| | | | | | the inner GEP is not a ConstantInt. llvm-svn: 98359
* Constant-fold GEP-of-GEP into a single GEP.Dan Gohman2010-03-101-0/+11
| | | | llvm-svn: 98178
* Remove the code which constant-folded ptrtoint(inttoptr(x)+c) toDan Gohman2010-02-231-37/+5
| | | | | | | | | | | getelementptr. Despite only doing so in the case where x is a known array object and c can be converted to an index within range, this could still be invalid if c is actually the address of an object allocated outside of LLVM. Also, SCEVExpander, the original motivation for this code, has since been improved to avoid inttoptr+ptroint in more cases. llvm-svn: 96950
* Canonicalize ConstantInts to the right operand of commutativeDan Gohman2010-02-221-2/+2
| | | | | | | | | | operators. The test difference is just due to the multiplication operands being commuted (and thus requiring a more elaborate match). In optimized code, that expression would be folded. llvm-svn: 96816
* Minor formatting cleanup.Dan Gohman2010-02-221-2/+1
| | | | llvm-svn: 96808
* Fold bswap(undef) to undef.Dan Gohman2010-02-171-0/+6
| | | | llvm-svn: 96432
* There are two ways of checking for a given type, for example isa<PointerType>(T)Duncan Sands2010-02-161-2/+2
| | | | | | | and T->isPointerTy(). Convert most instances of the first form to the second form. Requested by Chris. llvm-svn: 96344
* Uniformize the names of type predicates: rather than having isFloatTy andDuncan Sands2010-02-151-2/+2
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* Add const qualifiers.Dan Gohman2010-02-081-2/+2
| | | | llvm-svn: 95582
* Generalize target-independent folding rules for sizeof to handle moreDan Gohman2010-02-011-0/+38
| | | | | | | | | | | | | | | | | | | cases, and implement target-independent folding rules for alignof and offsetof. Also, reassociate reassociative operators when it leads to more folding. Generalize ScalarEvolution's isOffsetOf to recognize offsetof on arrays. Rename getAllocSizeExpr to getSizeOfExpr, and getFieldOffsetExpr to getOffsetOfExpr, for consistency with analagous ConstantExpr routines. Make the target-dependent folder promote GEP array indices to pointer-sized integers, to make implicit casting explicit and exposed to subsequent folding. And add a bunch of testcases for this new functionality, and a bunch of related existing functionality. llvm-svn: 94987
* fix PR5978 by peeling the loop so that we avoid shifting theChris Lattner2010-01-081-2/+2
| | | | | | | result int by 8 for the first byte. While normally harmless, if the result is smaller than a byte, this shift is invalid. llvm-svn: 93018
* constant fold nasty constant expressions formed by llvm-gcc,Chris Lattner2010-01-021-3/+16
| | | | | | wrapping up PR3351. llvm-svn: 92410
* Fix PR5551 by not ignoring the top level constantexpr whenChris Lattner2009-12-041-1/+1
| | | | | | folding a load from constant. llvm-svn: 90545
* fix PR5673 by being more careful about pointers to functions.Chris Lattner2009-12-031-3/+10
| | | | llvm-svn: 90369
* Teach ConstantFolding to do a better job when folding gep(bitcast).Nick Lewycky2009-11-291-0/+1
| | | | | | This permits the devirtualization of llvm.org/PR3100#c9 when compiled by clang. llvm-svn: 90099
* Make ConstantFoldConstantExpression recursively visit the entireDan Gohman2009-11-231-2/+11
| | | | | | | | | | ConstantExpr, not just the top-level operator. This allows it to fold many more constants. Also, make GlobalOpt call ConstantFoldConstantExpression on GlobalVariable initializers. llvm-svn: 89659
* fix ConstantFoldCompareInstOperands to take the LHS/RHS asChris Lattner2009-11-091-23/+18
| | | | | | individual operands instead of taking a temporary array llvm-svn: 86619
* remove a bunch of extraneous LLVMContext argumentsChris Lattner2009-11-061-72/+60
| | | | | | from various APIs, addressing PR5325. llvm-svn: 86231
OpenPOWER on IntegriCloud