summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Teach FoldBitCast to be able to handle bitcasts from (e.g.) i128 -> <4 x float>.Chris Lattner2009-10-251-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to simplify this: union vec2d { double e[2]; double v __attribute__((vector_size(16))); }; typedef union vec2d vec2d; static vec2d a={{1,2}}, b={{3,4}}; vec2d foo () { return (vec2d){ .v = a.v + b.v * (vec2d){{5,5}}.v }; } down to: define %0 @foo() nounwind ssp { entry: %mrv5 = insertvalue %0 undef, double 1.600000e+01, 0 ; <%0> [#uses=1] %mrv6 = insertvalue %0 %mrv5, double 2.200000e+01, 1 ; <%0> [#uses=1] ret %0 %mrv6 } instead of: define %0 @foo() nounwind ssp { entry: %mrv5 = insertvalue %0 undef, double extractelement (<2 x double> fadd (<2 x double> fmul (<2 x double> bitcast (<1 x i128> <i128 85174437667405312423031577302488055808> to <2 x double>), <2 x double> <double 3.000000e+00, double 4.000000e+00>), <2 x double> <double 1.000000e+00, double 2.000000e+00>), i32 0), 0 ; <%0> [#uses=1] %mrv6 = insertvalue %0 %mrv5, double extractelement (<2 x double> fadd (<2 x double> fmul (<2 x double> bitcast (<1 x i128> <i128 85174437667405312423031577302488055808> to <2 x double>), <2 x double> <double 3.000000e+00, double 4.000000e+00>), <2 x double> <double 1.000000e+00, double 2.000000e+00>), i32 1), 1 ; <%0> [#uses=1] ret %0 %mrv6 } llvm-svn: 85040
* move FoldBitCast earlier in the file, and use it instead of Chris Lattner2009-10-251-132/+132
| | | | | | ConstantExpr::getBitCast in various places. llvm-svn: 85039
* refactor FoldBitCast to reduce nesting and to always return a constantexprChris Lattner2009-10-251-104/+109
| | | | | | instead of returning null on failure. No functionality change. llvm-svn: 85038
* various cleanups suggested by DuncanChris Lattner2009-10-241-3/+5
| | | | llvm-svn: 84993
* fix PR5287, a serious regression from my previous patches. Thanks toChris Lattner2009-10-241-0/+1
| | | | | | Duncan for the nice tiny testcase. llvm-svn: 84992
* teach libanalysis to simplify vector loads with bitcast sources. ThisChris Lattner2009-10-231-7/+13
| | | | | | | | | | | | | | | | | | | | | | implements something out of Target/README.txt producing: _foo: ## @foo movl 4(%esp), %eax movapd LCPI1_0, %xmm0 movapd %xmm0, (%eax) ret $4 instead of: _foo: ## @foo movl 4(%esp), %eax movapd _b, %xmm0 mulpd LCPI1_0, %xmm0 addpd _a, %xmm0 movapd %xmm0, (%eax) ret $4 llvm-svn: 84942
* enhance FoldReinterpretLoadFromConstPtr to handle loads of up to 32 Chris Lattner2009-10-231-6/+8
| | | | | | bytes (i256). llvm-svn: 84941
* teach libanalysis to fold int and fp loads from almost arbitraryChris Lattner2009-10-231-8/+185
| | | | | | | | | | | | | | | | | | | non-type-safe constant initializers. This sort of thing happens quite a bit for 4-byte loads out of string constants, unions, bitfields, and an interesting endianness check from sqlite, which is something like this: const int sqlite3one = 1; # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) # define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) all of these macros now constant fold away. This implements PR3152 and is based on a patch started by Eli, but heavily modified and extended. llvm-svn: 84936
* move another load optimization from instcombine -> libanalysis.Chris Lattner2009-10-221-34/+48
| | | | llvm-svn: 84841
* move 'loading i32 from string' optimization from instcombineChris Lattner2009-10-221-6/+35
| | | | | | | to libanalysis. Instcombine shrinking... does this even make sense??? llvm-svn: 84840
* Move some constant folding logic for loads out of instcombine intoChris Lattner2009-10-221-0/+35
| | | | | | | | | Analysis/ConstantFolding.cpp. This doesn't change the behavior of instcombine but makes other clients of ConstantFoldInstruction able to handle loads. This was partially extracted from Eli's patch in PR3152. llvm-svn: 84836
* Extend ConstantFolding to understand signed overflow variantsEvan Phoenix2009-10-051-0/+24
| | | | llvm-svn: 83338
* Remove an unnnecessary LLVMContext argument inDan Gohman2009-10-051-2/+1
| | | | | | ConstantFoldLoadThroughGEPConstantExpr. llvm-svn: 83311
* teach the optimizer how to constant fold uadd/usub intrinsics.Chris Lattner2009-10-051-1/+29
| | | | llvm-svn: 83295
* simplify this code a bunch.Chris Lattner2009-10-051-14/+14
| | | | llvm-svn: 83294
* code simplifications.Chris Lattner2009-10-051-16/+25
| | | | llvm-svn: 83292
* simplify some codeChris Lattner2009-09-161-6/+5
| | | | llvm-svn: 81961
* Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword andDan Gohman2009-09-111-6/+2
| | | | | | | | | | | | | how to fold notionally-out-of-bounds array getelementptr indices instead of just doing these in lib/Analysis/ConstantFolding.cpp, because it can be done in a fairly general way without TargetData, and because not all constants are visited by lib/Analysis/ConstantFolding.cpp. This enables more constant folding. Also, set the "inbounds" flag when the getelementptr indices are one-past-the-end. llvm-svn: 81483
OpenPOWER on IntegriCloud