summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
Commit message (Collapse)AuthorAgeFilesLines
* Fix isEliminableCastPair to work correctly in the presence of pointersDuncan Sands2012-10-301-6/+10
| | | | | | with different sizes. llvm-svn: 167018
* Enable some additional constant folding for PPCDoubleDouble.Ulrich Weigand2012-10-301-4/+2
| | | | | | This fixes Clang :: CodeGen/complex-builtints.c on PowerPC. llvm-svn: 167013
* Add some cleanup to the DataLayout changes requested by Chandler.Micah Villmow2012-10-241-2/+1
| | | | llvm-svn: 166607
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-246-200/+201
| | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
* Fix typo that somehow escaped both testing and code inspection.Duncan Sands2012-10-231-1/+1
| | | | llvm-svn: 166475
* Transform code like thisDuncan Sands2012-10-232-52/+305
| | | | | | | | | | | | | | | | | | | | | | | | | | | %V = mul i64 %N, 4 %t = getelementptr i8* bitcast (i32* %arr to i8*), i32 %V into %t1 = getelementptr i32* %arr, i32 %N %t = bitcast i32* %t1 to i8* incorporating the multiplication into the getelementptr. This happens all the time in dragonegg, for example for int foo(int *A, int N) { return A[N]; } because gcc turns this into byte pointer arithmetic before it hits the plugin: D.1590_2 = (long unsigned int) N_1(D); D.1591_3 = D.1590_2 * 4; D.1592_5 = A_4(D) + D.1591_3; D.1589_6 = *D.1592_5; return D.1589_6; The D.1592_5 line is a POINTER_PLUS_EXPR, which is turned into a getelementptr on a bitcast of A_4 to i8*, so this becomes exactly the kind of IR that the transform fires on. An analogous transform (with no testcases!) already existed for bitcasts of arrays, so I rewrote it to share code with this one. llvm-svn: 166474
* InstCombine: Fix an edge case where constant icmps could sneak into ↵Benjamin Kramer2012-10-201-0/+4
| | | | | | | | ConstantFoldInstOperands and crash. Have to refactor the ConstantFolder interface one day to define bugs like this away. Fixes PR14131. llvm-svn: 166374
* [InstCombine] Teach InstCombine how to handle an obfuscated splat.Michael Gottesman2012-10-161-2/+5
| | | | | | | | | | | | An obfuscated splat is where the frontend poorly generates code for a splat using several different shuffles to create the splat, i.e., %A = load <4 x float>* %in_ptr, align 16 %B = shufflevector <4 x float> %A, <4 x float> undef, <4 x i32> <i32 0, i32 0, i32 undef, i32 undef> %C = shufflevector <4 x float> %B, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 4, i32 undef> %D = shufflevector <4 x float> %C, <4 x float> %A, <4 x i32> <i32 0, i32 1, i32 2, i32 4> llvm-svn: 166061
* Move the Attributes::Builder outside of the Attributes class and into its ↵Bill Wendling2012-10-151-3/+3
| | | | | | own class named AttrBuilder. No functionality change. llvm-svn: 165960
* Resubmit the changes to llvm core to update the functions to support ↵Micah Villmow2012-10-152-7/+12
| | | | | | different pointer sizes on a per address space basis. llvm-svn: 165941
* Add an enum for the return and function indexes into the AttrListPtr object. ↵Bill Wendling2012-10-151-4/+8
| | | | | | This gets rid of some magic numbers. llvm-svn: 165924
* Attributes RewriteBill Wendling2012-10-151-1/+2
| | | | | | | | | | Convert the internal representation of the Attributes class into a pointer to an opaque object that's uniqued by and stored in the LLVMContext object. The Attributes class then becomes a thin wrapper around this opaque object. Eventually, the internal representation will be expanded to include attributes that represent code generation options, etc. llvm-svn: 165917
* Remove operator cast method in favor of querying with the correct method.Bill Wendling2012-10-141-6/+12
| | | | llvm-svn: 165899
* Remove the bitwise AND operators from the Attributes class. Replace it with ↵Bill Wendling2012-10-141-1/+2
| | | | | | the equivalent from the builder class. llvm-svn: 165896
* Implement new LibCallSimplifier classMeador Inge2012-10-133-36/+9
| | | | | | | | | | | | | | | | This patch implements the new LibCallSimplifier class as outlined in [1]. In addition to providing the new base library simplification infrastructure, all the fortified library call simplifications were moved over to the new infrastructure. The rest of the library simplification optimizations will be moved over with follow up patches. NOTE: The original fortified library call simplifier located in the SimplifyFortifiedLibCalls class was not removed because it is still used by CodeGenPrepare. This class will eventually go away too. [1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-August/052283.html llvm-svn: 165873
* Revert 165732 for further review.Micah Villmow2012-10-112-12/+7
| | | | llvm-svn: 165747
* Add in the first iteration of support for llvm/clang/lldb to allow variable ↵Micah Villmow2012-10-112-7/+12
| | | | | | per address space pointer sizes to be optimized correctly. llvm-svn: 165726
* Don't crash when !tbaa.struct contents is invalid.Nick Lewycky2012-10-111-0/+3
| | | | llvm-svn: 165693
* Create enums for the different attributes.Bill Wendling2012-10-091-3/+3
| | | | | | | We use the enums to query whether an Attributes object has that attribute. The opaque layer is responsible for knowing where that specific attribute is stored. llvm-svn: 165488
* Convert to using the Attributes::Builder interface.Bill Wendling2012-10-091-12/+13
| | | | llvm-svn: 165465
* Move TargetData to DataLayout.Micah Villmow2012-10-0812-33/+33
| | | | llvm-svn: 165402
* Surprisingly, we missed a trivial case here. Fix that!Nick Lewycky2012-09-281-0/+4
| | | | llvm-svn: 164814
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-278-39/+39
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164767 llvm-svn: 164768
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-278-39/+39
| | | | llvm-svn: 164767
* Prefer shuffles to selects. Backends love shuffles!Nick Lewycky2012-09-271-1/+19
| | | | llvm-svn: 164763
* Move Attribute::typeIncompatible inside of the Attributes class.Bill Wendling2012-09-251-3/+3
| | | | llvm-svn: 164629
* Add missing check for presence of target data.Richard Osborne2012-09-241-20/+22
| | | | | | This avoids a crash in visitAllocaInst when target data isn't available. llvm-svn: 164539
* InstCombine: Make sure we use the pre-zext type when creating a constant of ↵Benjamin Kramer2012-09-211-1/+2
| | | | | | | | a value that is zext'd. Fixes PR13250. llvm-svn: 164377
* Fix instcombine to obey requested alignment when merging allocas.Richard Osborne2012-09-181-3/+7
| | | | llvm-svn: 164117
* Use LLVM_DELETED_FUNCTION in place of 'DO NOT IMPLEMENT' comments.Craig Topper2012-09-151-2/+2
| | | | llvm-svn: 163974
* Handle the new !tbaa.struct metadata tags when converting a memcpy into scalarDan Gohman2012-09-131-0/+17
| | | | | | loads and stores. llvm-svn: 163844
* Extract code for reducing a type to a single value type into a helper function.Dan Gohman2012-09-131-15/+21
| | | | llvm-svn: 163817
* InstCombine: Fix comment to reflect the code.Benjamin Kramer2012-08-301-1/+1
| | | | llvm-svn: 162911
* It is illegal to transform (sdiv (ashr X c1) c2) -> (sdiv x (2^c1 * c2)),Nadav Rotem2012-08-301-10/+0
| | | | | | | | because C always rounds towards zero. Thanks Dirk and Ben. llvm-svn: 162899
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-292-10/+11
| | | | | | | | | | | | | | | | This disables malloc-specific optimization when -fno-builtin (or -ffreestanding) is specified. This has been a problem for a long time but became more severe with the recent memory builtin improvements. Since the memory builtin functions are used everywhere, this required passing TLI in many places. This means that functions that now have an optional TLI argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead mallocs anymore if the TLI argument is missing. I've updated most passes to do the right thing. Fixes PR13694 and probably others. llvm-svn: 162841
* InstCombine: Defensively avoid undefined shifts by limiting the amount to ↵Benjamin Kramer2012-08-281-2/+2
| | | | | | | | | the bit width. No test case, undefined shifts get folded early, but can occur when other transforms generate a constant. Thanks to Duncan for bringing this up. llvm-svn: 162755
* InstCombine: Guard the transform introduced in r162743 against large ints ↵Benjamin Kramer2012-08-281-10/+10
| | | | | | and non-const shifts. llvm-svn: 162751
* Make sure that we don't call getZExtValue on values > 64 bits.Nadav Rotem2012-08-281-8/+8
| | | | | | Thanks Benjamin for noticing this. llvm-svn: 162749
* Teach InstCombine to canonicalize [SU]div+[AL]shl patterns.Nadav Rotem2012-08-281-0/+20
| | | | | | | | | | For example: %1 = lshr i32 %x, 2 %2 = udiv i32 %1, 100 rdar://12182093 llvm-svn: 162743
* Port the global copy optimization from the SROA pass to InstCombine.Chandler Carruth2012-08-211-1/+171
| | | | | | | | | | This optimization is really just replacing allocas wholesale with globals, there is no scalarization. The underlying motivation for this patch is to simplify the SROA pass and focus it on splitting and promoting allocas. llvm-svn: 162271
* InstCombine: Fix a crasher when encountering a function pointer.Benjamin Kramer2012-08-181-1/+1
| | | | llvm-svn: 162180
* Remove overly conservative hasOneUse check, this always expands into a ↵Benjamin Kramer2012-08-181-1/+1
| | | | | | single IR instruction. llvm-svn: 162175
* InstCombine: Add a couple of fabs identities for comparing with 0.0.Benjamin Kramer2012-08-181-0/+39
| | | | llvm-svn: 162174
* fix infinite loop in instcombine with more than 4GB memcpyMichael Liao2012-08-151-6/+4
| | | | | | | | | | | | - memcpy size is wrongly truncated into 32-bit and treat 8GB memcpy is 0-sized memcpy - as 0-sized memcpy/memset is already removed before SimplifyMemTransfer and SimplifyMemSet in visitCallInst, replace 0 checking with assertions. - replace getZExtValue() with getLimitedValue() according to Eli Friedman llvm-svn: 161923
* Fix a serious typo in InstCombine's optimization of comparisons.Bob Wilson2012-08-071-1/+1
| | | | | | | | | An unsigned value converted to floating-point will always be greater than a negative constant. Unfortunately InstCombine reversed the check so that unsigned values were being optimized to always be greater than all positive floating-point constants. <rdar://problem/12029145> llvm-svn: 161452
* fix infinite loop in instcombine in the presence of a (malformed) ↵Nuno Lopes2012-07-271-0/+4
| | | | | | | | self-referencing select inst. This can happen as long as the instruction is not reachable. Instcombine does generate these unreachable malformed selects when doing RAUW llvm-svn: 160874
* Simplify demanded bits of select sources where the condition is a constant ↵Pete Cooper2012-07-262-0/+34
| | | | | | vector llvm-svn: 160835
* Teach SimplifyDemandedBits how to look through fpext and fptrunc to simplify ↵Pete Cooper2012-07-261-0/+6
| | | | | | their operand llvm-svn: 160823
* make all Emit*() functions consult the TargetLibraryInfo information before ↵Nuno Lopes2012-07-251-1/+1
| | | | | | | | | creating a call to a library function. Update all clients to pass the TLI information around. Previous draft reviewed by Eli. llvm-svn: 160733
* Remove tabs.Bill Wendling2012-07-191-1/+1
| | | | llvm-svn: 160477
OpenPOWER on IntegriCloud