summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* testcase for PR3381.Torok Edwin2009-01-241-1/+1
| | | | | | Also it was an empty struct, not a void after all. llvm-svn: 62920
* void* is represented as pointer to empty struct {}.Torok Edwin2009-01-241-0/+2
| | | | | | | Thus we need to check whether the struct is empty before trying to index into it. This fixes PR3381. llvm-svn: 62918
* Make InstCombineStoreToCast handle aggregates more aggressively,Chris Lattner2009-01-241-18/+48
| | | | | | | handling the case in Transforms/InstCombine/cast-store-gep.ll, which is a heavily reduced testcase from Clang on x86-64. llvm-svn: 62904
* Remove uses of uint32_t in favor of 'unsigned' for better Chris Lattner2009-01-211-1/+1
| | | | | | compatibility with cygwin. Patch by Jay Foad! llvm-svn: 62695
* Make special cases (0 inf nan) work for frem.Dale Johannesen2009-01-211-5/+5
| | | | | | | | Besides APFloat, this involved removing code from two places that thought they knew the result of frem(0., x) but were wrong. llvm-svn: 62645
* Fix PR3335 by not turning a store to one address space into a store to another.Chris Lattner2009-01-161-1/+5
| | | | llvm-svn: 62351
* reduce indentation by using early exits, no functionality change.Chris Lattner2009-01-161-44/+47
| | | | llvm-svn: 62350
* Clean up previous cast optimization a bit. Also make zext elimination a bit ↵Evan Cheng2009-01-161-30/+55
| | | | | | more aggressive: if it's not necessary to emit an AND (i.e. high bits are already zero), it's profitable to evaluate the operand at a different type. llvm-svn: 62297
* Eliminate a redundant check.Evan Cheng2009-01-151-2/+1
| | | | llvm-svn: 62264
* - Teach CanEvaluateInDifferentType of this xform: sext (zext ty1), ty2 -> ↵Evan Cheng2009-01-151-22/+51
| | | | | | | | zext ty2 - Looking at the number of sign bits of the a sext instruction to determine whether new trunc + sext pair should be added when its source is being evaluated in a different type. llvm-svn: 62263
* Make instcombine ensure that all allocas are explicitly aligned at atDan Gohman2009-01-131-6/+11
| | | | | | least their preferred alignment. llvm-svn: 62176
* Rename getABITypeSize to getTypePaddedSize, asDuncan Sands2009-01-121-15/+15
| | | | | | suggested by Chris. llvm-svn: 62099
* Duncan is nervous about undefinedness of % with negatives. I'mChris Lattner2009-01-111-1/+1
| | | | | | not thrilled about 64-bit % in general, so rewrite to use * instead. llvm-svn: 62047
* do not generated GEPs into vectors where they don't already exist.Chris Lattner2009-01-111-4/+3
| | | | | | We should treat vectors as atomic types, not like arrays. llvm-svn: 62046
* Make a couple of cleanups to the instcombine bitcast/gep Chris Lattner2009-01-111-12/+13
| | | | | | | | | | | | | canonicalization transform based on duncan's comments: 1) improve the comment about %. 2) within our index loop make sure the offset stays within the *type size*, instead of within the *abi size*. This allows us to reason explicitly about landing in tail padding and means that issues like non-zero offsets into [0 x foo] types don't occur anymore. llvm-svn: 62045
* fix typo Duncan noticed.Chris Lattner2009-01-091-1/+1
| | | | llvm-svn: 61997
* Implement rdar://6480391, extending of equality icmp's to avoid a truncation.Chris Lattner2009-01-091-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed this in the code compiled for a routine using std::map, which produced this code: %25 = tail call i32 @memcmp(i8* %24, i8* %23, i32 6) nounwind readonly %.lobit.i = lshr i32 %25, 31 ; <i32> [#uses=1] %tmp.i = trunc i32 %.lobit.i to i8 ; <i8> [#uses=1] %toBool = icmp eq i8 %tmp.i, 0 ; <i1> [#uses=1] br i1 %toBool, label %bb3, label %bb4 which compiled to: call L_memcmp$stub shrl $31, %eax testb %al, %al jne LBB1_11 ## with this change, we compile it to: call L_memcmp$stub testl %eax, %eax js LBB1_11 This triggers all the time in common code, with patters like this: %169 = and i32 %ply, 1 ; <i32> [#uses=1] %170 = trunc i32 %169 to i8 ; <i8> [#uses=1] %toBool = icmp ne i8 %170, 0 ; <i1> [#uses=1] %7 = lshr i32 %6, 24 ; <i32> [#uses=1] %9 = trunc i32 %7 to i8 ; <i8> [#uses=1] %10 = icmp ne i8 %9, 0 ; <i1> [#uses=1] etc llvm-svn: 61985
* Remove some old code that looks like a remanant from signed-types days.Chris Lattner2009-01-091-23/+0
| | | | llvm-svn: 61984
* Fix part 3/2 of PR3290, making instcombine zap (gep(bitcast)) when possible.Chris Lattner2009-01-091-81/+116
| | | | llvm-svn: 61980
* move some code, check to see if the input to the GEP is a bitcastChris Lattner2009-01-091-23/+22
| | | | | | (which is constant time and cheap) before checking hasAllZeroIndices. llvm-svn: 61976
* Change m_ConstantInt and m_SelectCst to take their constant integersChris Lattner2009-01-051-9/+9
| | | | | | | as template arguments instead of as instance variables, exposing more optimization opportunities to the compiler earlier. llvm-svn: 61776
* Revert this transform. It was causing some dramatic slowdowns in a few ↵Bill Wendling2009-01-041-31/+0
| | | | | | tests. See PR3266. llvm-svn: 61623
* Fix comment.Bill Wendling2009-01-011-1/+1
| | | | llvm-svn: 61538
* Add transformation:Bill Wendling2009-01-011-1/+32
| | | | | | | | xor (or (icmp, icmp), true) -> and(icmp, icmp) This is possible because of De Morgan's law. llvm-svn: 61537
* Remove redundant test for vector-nature. Scan the vector first to see whetherNick Lewycky2008-12-201-4/+10
| | | | | | our optz'n will apply to it, then build the replacement vector only if needed. llvm-svn: 61279
* Oops! Left out a line.Nick Lewycky2008-12-181-0/+1
| | | | | | Simplifying the sdiv might allow further simplifications for our users. llvm-svn: 61196
* Make all the vector elements positive in an srem of constant vector.Nick Lewycky2008-12-181-0/+23
| | | | llvm-svn: 61195
* Remove some errors that crept in. No functionality change.Bill Wendling2008-12-021-3/+4
| | | | llvm-svn: 60403
* Merge two if-statements into one.Bill Wendling2008-12-021-7/+3
| | | | llvm-svn: 60402
* More styalistic changes. No functionality change.Bill Wendling2008-12-021-15/+12
| | | | llvm-svn: 60401
* - Remove the buggy -X/C -> X/-C transform. This isn't valid when X isn't aBill Wendling2008-12-021-12/+0
| | | | | | | | | constant. If X is a constant, then this is folded elsewhere. - Added a note to Target/README.txt to indicate that we'd like to implement this when we're able. llvm-svn: 60399
* Improve comment.Bill Wendling2008-12-021-4/+3
| | | | llvm-svn: 60398
* - Reduce nesting.Bill Wendling2008-12-021-24/+18
| | | | | | | | - No need to do a swap on a canonicalized pattern. No functionality change. llvm-svn: 60397
* Don't rebuild RHSNeg. Just use the one that's already there.Bill Wendling2008-12-011-2/+1
| | | | llvm-svn: 60370
* Document what this check is doing. Also, no need to cast to ConstantInt.Bill Wendling2008-12-011-4/+4
| | | | llvm-svn: 60369
* Use a simple comparison. Overflow on integer negation can only occur when theBill Wendling2008-12-011-13/+2
| | | | | | integer is "minint". llvm-svn: 60366
* Generalize the FoldOrWithConstant method to fold for any two constants whichBill Wendling2008-12-011-23/+22
| | | | | | don't have overlapping bits. llvm-svn: 60344
* Reduce copy-and-paste code by splitting out the code into its own function.Bill Wendling2008-12-011-58/+50
| | | | llvm-svn: 60343
* Use m_Specific() instead of double matching.Bill Wendling2008-12-011-18/+12
| | | | llvm-svn: 60341
* Move pattern check outside of the if-then statement. This prevents us from ↵Bill Wendling2008-12-011-10/+12
| | | | | | fiddling with constants unless we have to. llvm-svn: 60340
* simplify these patterns using m_Specific. No need to grep for Chris Lattner2008-12-011-16/+6
| | | | | | xor in testcase (or is a substring). llvm-svn: 60328
* Change instcombine to use FoldPHIArgGEPIntoPHI to fold two operand PHIsChris Lattner2008-12-011-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of using FoldPHIArgBinOpIntoPHI. In addition to being more obvious, this also fixes a problem where instcombine wouldn't merge two phis that had different variable indices. This prevented instcombine from factoring big chunks of code in 403.gcc. For example: insn_cuid.exit: - %tmp336 = load i32** @uid_cuid, align 4 - %tmp337 = getelementptr %struct.rtx_def* %insn_addr.0.ph.i, i32 0, i32 3 - %tmp338 = bitcast [1 x %struct.rtunion]* %tmp337 to i32* - %tmp339 = load i32* %tmp338, align 4 - %tmp340 = getelementptr i32* %tmp336, i32 %tmp339 br label %bb62 bb61: - %tmp341 = load i32** @uid_cuid, align 4 - %tmp342 = getelementptr %struct.rtx_def* %insn, i32 0, i32 3 - %tmp343 = bitcast [1 x %struct.rtunion]* %tmp342 to i32* - %tmp344 = load i32* %tmp343, align 4 - %tmp345 = getelementptr i32* %tmp341, i32 %tmp344 br label %bb62 bb62: - %iftmp.62.0.in = phi i32* [ %tmp345, %bb61 ], [ %tmp340, %insn_cuid.exit ] + %insn.pn2 = phi %struct.rtx_def* [ %insn, %bb61 ], [ %insn_addr.0.ph.i, %insn_cuid.exit ] + %tmp344.pn.in.in = getelementptr %struct.rtx_def* %insn.pn2, i32 0, i32 3 + %tmp344.pn.in = bitcast [1 x %struct.rtunion]* %tmp344.pn.in.in to i32* + %tmp341.pn = load i32** @uid_cuid + %tmp344.pn = load i32* %tmp344.pn.in + %iftmp.62.0.in = getelementptr i32* %tmp341.pn, i32 %tmp344.pn %iftmp.62.0 = load i32* %iftmp.62.0.in llvm-svn: 60325
* Teach inst combine to merge GEPs through PHIs. This is reallyChris Lattner2008-12-011-16/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | important because it is sinking the loads using the GEPs, but not the GEPs themselves. This triggers 647 times on 403.gcc and makes the .s file much much nicer. For example before: je LBB1_87 ## bb78 LBB1_62: ## bb77 leal 84(%esi), %eax LBB1_63: ## bb79 movl (%eax), %eax ... LBB1_87: ## bb78 movl $0, 4(%esp) movl %esi, (%esp) call L_make_decl_rtl$stub jmp LBB1_62 ## bb77 after: jne LBB1_63 ## bb79 LBB1_62: ## bb78 movl $0, 4(%esp) movl %esi, (%esp) call L_make_decl_rtl$stub LBB1_63: ## bb79 movl 84(%esi), %eax The input code was (and the GEPs are merged and the PHI is now eliminated by instcombine): br i1 %tmp233, label %bb78, label %bb77 bb77: %tmp234 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22 br label %bb79 bb78: call void @make_decl_rtl(%struct.tree_node* %t_addr.3, i8* null) nounwind %tmp235 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22 br label %bb79 bb79: %iftmp.12.0.in = phi %struct.rtx_def** [ %tmp235, %bb78 ], [ %tmp234, %bb77 ] %iftmp.12.0 = load %struct.rtx_def** %iftmp.12.0.in llvm-svn: 60322
* Implement ((A|B)&1)|(B&-2) -> (A&1) | B transformation. This also takes care ofBill Wendling2008-12-011-0/+67
| | | | | | permutations of this pattern. llvm-svn: 60312
* Minor cleanup: use getTrue and getFalse where appropriate. No Eli Friedman2008-11-301-20/+20
| | | | | | functional change. llvm-svn: 60307
* Some minor cleanups to instcombine; no functionality change.Eli Friedman2008-11-301-56/+17
| | | | | | | Note that the FoldOpIntoPhi call is dead because it's impossible for the first operand of a subtraction to be both a ConstantInt and a PHINode. llvm-svn: 60306
* Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all permutations.Bill Wendling2008-11-301-0/+23
| | | | llvm-svn: 60291
* Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. ThisBill Wendling2008-11-301-0/+19
| | | | | | takes care of all permutations of this pattern. llvm-svn: 60290
* Forgot one remaining call to getSExtValue().Bill Wendling2008-11-301-1/+1
| | | | llvm-svn: 60289
* getSExtValue() doesn't work for ConstantInts with bitwidth > 64 bits. Use allBill Wendling2008-11-301-5/+5
| | | | | | | | APInt calls instead. This fixes PR3144. llvm-svn: 60288
OpenPOWER on IntegriCloud