summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Make instcombine promote inline asm calls to 'nounwind'Duncan Sands2007-12-161-0/+13
| | | | | | | | | | | | | calls. Remove special casing of inline asm from the inliner. There is a potential problem: the verifier rejects invokes of inline asm (not sure why). If an asm call is not marked "nounwind" in some .ll, and instcombine is not run, but the inliner is run, then an illegal module will be created. This is bad but I'm not sure what the best approach is. I'm tempted to remove the check in the verifier... llvm-svn: 45073
* 1. "Upgrage" comments.Wojciech Matyjewicz2007-12-121-15/+16
| | | | | | | | | | | | | | 2. Using zero-extended value of Scale and unsigned division is safe provided that Scale doesn't have the sign bit set. Previously these 2 instructions: %p = bitcast [100 x {i8,i8,i8}]* %x to i8* %q = getelementptr i8* %p, i32 -4 were combined into: %q = getelementptr [100 x { i8, i8, i8 }]* %x, i32 0, i32 1431655764, i32 0 what was incorrect. llvm-svn: 44936
* simplify some code.Chris Lattner2007-12-061-2/+1
| | | | llvm-svn: 44655
* move some ashr-specific code out of commonShiftTransforms into visitAShr.Chris Lattner2007-12-061-15/+16
| | | | llvm-svn: 44650
* Fix PR1146: parameter attributes are longer part ofDuncan Sands2007-11-271-11/+18
| | | | | | | | | | | | the function type, instead they belong to functions and function calls. This is an updated and slightly corrected version of Reid Spencer's original patch. The only known problem is that auto-upgrading of bitcode files doesn't seem to work properly (see test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully a bitcode guru (who might that be? :) ) will fix it. llvm-svn: 44359
* Implement PR1822Chris Lattner2007-11-251-0/+7
| | | | llvm-svn: 44318
* Fix PR1816. If a bitcast of a function only exists because of aDuncan Sands2007-11-251-4/+5
| | | | | | | | | trivial difference in function attributes, allow calls to it to be converted to direct calls. Based on a patch by Török Edwin. While there, move the various lists of mutually incompatible parameters etc out of the verifier and into ParameterAttributes.h. llvm-svn: 44315
* add a comment.Chris Lattner2007-11-231-1/+1
| | | | llvm-svn: 44293
* Fix PR1817.Chris Lattner2007-11-221-1/+6
| | | | llvm-svn: 44284
* Fix PR1800 by correcting mistaken logic.Chris Lattner2007-11-161-2/+1
| | | | llvm-svn: 44188
* Better checkAndrew Lenharth2007-11-081-1/+1
| | | | llvm-svn: 43897
* Fix PR1780Andrew Lenharth2007-11-081-1/+1
| | | | llvm-svn: 43893
* Implement PR1777 by detecting dependent phis thatChris Lattner2007-11-061-0/+62
| | | | | | all compute the same value. llvm-svn: 43777
* wrap long linesChris Lattner2007-11-061-2/+4
| | | | llvm-svn: 43745
* Fix an abort in instcombine when folding creates a vector rem instruction.Dan Gohman2007-11-051-5/+9
| | | | llvm-svn: 43743
* Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.Duncan Sands2007-11-011-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The meaning of getTypeSize was not clear - clarifying it is important now that we have x86 long double and arbitrary precision integers. The issue with long double is that it requires 80 bits, and this is not a multiple of its alignment. This gives a primitive type for which getTypeSize differed from getABITypeSize. For arbitrary precision integers it is even worse: there is the minimum number of bits needed to hold the type (eg: 36 for an i36), the maximum number of bits that will be overwriten when storing the type (40 bits for i36) and the ABI size (i.e. the storage size rounded up to a multiple of the alignment; 64 bits for i36). This patch removes getTypeSize (not really - it is still there but deprecated to allow for a gradual transition). Instead there is: (1) getTypeSizeInBits - a number of bits that suffices to hold all values of the type. For a primitive type, this is the minimum number of bits. For an i36 this is 36 bits. For x86 long double it is 80. This corresponds to gcc's TYPE_PRECISION. (2) getTypeStoreSizeInBits - the maximum number of bits that is written when storing the type (or read when reading it). For an i36 this is 40 bits, for an x86 long double it is 80 bits. This is the size alias analysis is interested in (getTypeStoreSize returns the number of bytes). There doesn't seem to be anything corresponding to this in gcc. (3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded up to a multiple of the alignment. For an i36 this is 64, for an x86 long double this is 96 or 128 depending on the OS. This is the spacing between consecutive elements when you form an array out of this type (getABITypeSize returns the number of bytes). This is TYPE_SIZE in gcc. Since successive elements in a SequentialType (arrays, pointers and vectors) need to be aligned, the spacing between them will be given by getABITypeSize. This means that the size of an array is the length times the getABITypeSize. It also means that GEP computations need to use getABITypeSize when computing offsets. Furthermore, if an alloca allocates several elements at once then these too need to be aligned, so the size of the alloca has to be the number of elements multiplied by getABITypeSize. Logically speaking this doesn't have to be the case when allocating just one element, but it is simpler to also use getABITypeSize in this case. So alloca's and mallocs should use getABITypeSize. Finally, since gcc's only notion of size is that given by getABITypeSize, if you want to output assembler etc the same as gcc then getABITypeSize is the size you want. Since a store will overwrite no more than getTypeStoreSize bytes, and a read will read no more than that many bytes, this is the notion of size appropriate for alias analysis calculations. In this patch I have corrected all type size uses except some of those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard cases). I will get around to auditing these too at some point, but I could do with some help. Finally, I made one change which I think wise but others might consider pointless and suboptimal: in an unpacked struct the amount of space allocated for a field is now given by the ABI size rather than getTypeStoreSize. I did this because every other place that reserves memory for a type (eg: alloca) now uses getABITypeSize, and I didn't want to make an exception for unpacked structs, i.e. I did it to make things more uniform. This only effects structs containing long doubles and arbitrary precision integers. If someone wants to pack these types more tightly they can always use a packed struct. llvm-svn: 43620
* Fix InstCombine/2007-10-31-RangeCrash.llChris Lattner2007-11-011-0/+8
| | | | llvm-svn: 43596
* simplify some code by using the new isNaN predicateChris Lattner2007-10-241-4/+2
| | | | llvm-svn: 43305
* Implement a couple of foldings for ordered and unordered comparisons,Chris Lattner2007-10-241-4/+44
| | | | | | implementing cases related to PR1738. llvm-svn: 43289
* Try again.Devang Patel2007-10-181-3/+36
| | | | | | | Instead of loading small global string from memory, use integer constant. llvm-svn: 43148
* Reverting r43070 for now. It's causing llc test failures.Evan Cheng2007-10-171-25/+0
| | | | llvm-svn: 43103
* Apply "Instead of loading small c string constant, use integer constant ↵Devang Patel2007-10-171-25/+28
| | | | | | directly" transformation while processing load instruction. llvm-svn: 43070
* Use immediate stores.Devang Patel2007-10-161-3/+25
| | | | llvm-svn: 43055
* Achieve same result but use fewer lines of code.Devang Patel2007-10-151-8/+7
| | | | llvm-svn: 42985
* Dest type is always i8 *. This allows some simplification.Devang Patel2007-10-121-33/+12
| | | | | | Do not filter memmove. llvm-svn: 42930
* Fix a bug in my patch last night that broke InstCombine/2007-10-12-Crash.llChris Lattner2007-10-121-1/+7
| | | | llvm-svn: 42920
* eliminate warningGabor Greif2007-10-121-1/+1
| | | | llvm-svn: 42892
* Fix some 80 column violations.Chris Lattner2007-10-121-35/+42
| | | | | | | | Fix DecomposeSimpleLinearExpr to handle simple constants better. Don't nuke gep(bitcast(allocation)) if the bitcast(allocation) will fold the allocation. This fixes PR1728 and Instcombine/malloc3.ll llvm-svn: 42891
* Lower memcpy if it makes sense.Devang Patel2007-10-111-0/+46
| | | | llvm-svn: 42864
* Tone down an overzealous optimization.Dale Johannesen2007-10-031-3/+21
| | | | llvm-svn: 42582
* Improve comment.Duncan Sands2007-09-191-1/+2
| | | | llvm-svn: 42132
* A global variable with external weak linkage can be null, whileDuncan Sands2007-09-191-2/+6
| | | | | | an alias could alias such a global variable. llvm-svn: 42130
* Instcombine x-((x/y)*y) into a remainder operator.Dan Gohman2007-09-171-1/+12
| | | | llvm-svn: 42035
* Factor the trampoline transformation into a subroutine.Duncan Sands2007-09-171-137/+148
| | | | llvm-svn: 42021
* Remove the assumption that FP's are either float orDale Johannesen2007-09-141-3/+6
| | | | | | | | | | | | | double from some of the many places in the optimizers it appears, and do something reasonable with x86 long double. Make APInt::dump() public, remove newline, use it to dump ConstantSDNode's. Allow APFloats in FoldingSet. Expand X86 backend handling of long doubles (conversions to/from int, mostly). llvm-svn: 41967
* silence a bogus gcc warning.Chris Lattner2007-09-141-1/+1
| | | | llvm-svn: 41949
* Turn calls to trampolines into calls to the underlyingDuncan Sands2007-09-111-0/+138
| | | | | | nested function. llvm-svn: 41844
* remove some dead code, this is handled by constant folding.Chris Lattner2007-09-101-8/+1
| | | | llvm-svn: 41819
* Don't zap back to back volatile load/storesChris Lattner2007-09-071-1/+1
| | | | llvm-svn: 41759
* Next round of APFloat changes.Dale Johannesen2007-09-061-1/+1
| | | | | | | | | | | | | | Use APFloat in UpgradeParser and AsmParser. Change all references to ConstantFP to use the APFloat interface rather than double. Remove the ConstantFP double interfaces. Use APFloat functions for constant folding arithmetic and comparisons. (There are still way too many places APFloat is just a wrapper around host float/double, but we're getting there.) llvm-svn: 41747
* Use isTrueWhenEqual. Thanks Chris!Nick Lewycky2007-09-061-8/+13
| | | | llvm-svn: 41741
* When the two operands of an icmp are equal, there are five possible predicatesNick Lewycky2007-09-061-1/+3
| | | | | | that would make the icmp true. Fixes PR1637. llvm-svn: 41740
* Forgot to obey 80 column rule. Fixing that.Chuck Rose III2007-09-051-1/+2
| | | | llvm-svn: 41725
* Added default parameters to GetElementPtrInstr constructor call. Visual ↵Chuck Rose III2007-09-051-1/+1
| | | | | | Studio 2k5 was getting confused and was unable to compile it. Suspected compiler error. llvm-svn: 41721
* Update GEP constructors to use an iterator interface to fixDavid Greene2007-09-041-10/+18
| | | | | | GLIBCXX_DEBUG issues. llvm-svn: 41697
* Cut off crazy computation. This helps PR1622 slightly.Chris Lattner2007-08-281-0/+4
| | | | llvm-svn: 41522
* Update InvokeInst to work like CallInstDavid Greene2007-08-271-1/+1
| | | | llvm-svn: 41506
* Transform a load from an undef/zero global into an undef/global even if weChris Lattner2007-08-111-0/+33
| | | | | | | | | | | | | | | | | | | | | have complex pointer manipulation going on. This allows us to compile stuff like this: __m128i foo(__m128i x){ static const unsigned int c_0[4] = { 0, 0, 0, 0 }; __m128i v_Zero = _mm_loadu_si128((__m128i*)c_0); x = _mm_unpacklo_epi8(x, v_Zero); return x; } into: _foo: xorps %xmm1, %xmm1 punpcklbw %xmm1, %xmm0 ret llvm-svn: 41022
* when we see a unaligned load from an insufficiently aligned global orChris Lattner2007-08-091-21/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | alloca, increase the alignment of the load, turning it into an aligned load. This allows us to compile: #include <xmmintrin.h> __m128i foo(__m128i x){ static const unsigned int c_0[4] = { 0, 0, 0, 0 }; __m128i v_Zero = _mm_loadu_si128((__m128i*)c_0); x = _mm_unpacklo_epi8(x, v_Zero); return x; } into: _foo: punpcklbw _c_0.5944, %xmm0 ret .data .lcomm _c_0.5944,16,4 # c_0.5944 instead of: _foo: movdqu _c_0.5944, %xmm1 punpcklbw %xmm1, %xmm0 ret .data .lcomm _c_0.5944,16,2 # c_0.5944 llvm-svn: 40971
* It's safe to fold not of fcmp.Nick Lewycky2007-08-061-3/+8
| | | | llvm-svn: 40870
OpenPOWER on IntegriCloud