summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Throttle back "fold select into operand" transformation. InstCombine should ↵Evan Cheng2009-03-311-52/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | not generate selects of two constants unless they are selects of 0 and 1. e.g. define i32 @t1(i32 %c, i32 %x) nounwind { %t1 = icmp eq i32 %c, 0 %t2 = lshr i32 %x, 18 %t3 = select i1 %t1, i32 %t2, i32 %x ret i32 %t3 } was turned into define i32 @t2(i32 %c, i32 %x) nounwind { %t1 = icmp eq i32 %c, 0 %t2 = select i1 %t1, i32 18, i32 0 %t3 = lshr i32 %x, %t2 ret i32 %t3 } For most targets, that means materializing two constants and then a select. e.g. On x86-64 movl %esi, %eax shrl $18, %eax testl %edi, %edi cmovne %esi, %eax ret => xorl %eax, %eax testl %edi, %edi movl $18, %ecx cmovne %eax, %ecx movl %esi, %eax shrl %cl, %eax ret Also, the optimizer and codegen can reason about shl / and / add, etc. by a constant. This optimization will hinder optimizations using ComputeMaskedBits. llvm-svn: 68142
* Fix PR3874 by restoring a condition I removed, but making it moreChris Lattner2009-03-251-1/+2
| | | | | | precise than it used to be. llvm-svn: 67662
* oops, I intended to remove this, not comment it out. Thanks Duncan!Chris Lattner2009-03-241-2/+1
| | | | llvm-svn: 67657
* canonicalize inttoptr and ptrtoint instructions which cast pointers Chris Lattner2009-03-241-5/+37
| | | | | | | | to/from integer types that are not intptr_t to convert to intptr_t then do an integer conversion to the dest type. This exposes the cast to the optimizer. llvm-svn: 67638
* two changes:Chris Lattner2009-03-241-45/+29
| | | | | | | | | | | 1. Make instcombine always canonicalize trunc x to i1 into an icmp(x&1). This exposes the AND to other instcombine xforms and is more of what the code generator expects. 2. Rewrite the remaining trunc pattern match to use 'match', which simplifies it a lot. llvm-svn: 67635
* Factorize out a concept - no functionality change.Duncan Sands2009-03-211-4/+3
| | | | llvm-svn: 67454
* Fix instcombine to not introduce undefined shifts when merging twoChris Lattner2009-03-201-2/+14
| | | | | | shifts together. This fixes PR3851. llvm-svn: 67411
* Don't load values out of global constants with weakDuncan Sands2009-03-201-3/+4
| | | | | | | | | linkage: the value may be replaced with something different at link time. (Frontends that want to allow values to be loaded out of weak constants can give their constants weak_odr linkage). llvm-svn: 67407
* Fix PR3826 - InstComb assert with vector shift, by not calling ↵Chris Lattner2009-03-181-7/+8
| | | | | | ComputeNumSignBits on a vector. llvm-svn: 67211
* Remove a condition which is always true.Chris Lattner2009-03-171-3/+3
| | | | llvm-svn: 67089
* One more place where debug info affects codegen.Dale Johannesen2009-03-131-1/+2
| | | | llvm-svn: 66930
* Oops...I committed too much.Bill Wendling2009-03-131-4/+3
| | | | llvm-svn: 66867
* Temporarily XFAIL this test.Bill Wendling2009-03-131-3/+4
| | | | llvm-svn: 66866
* Skip interleaved debug info when fast-forwarding throughDale Johannesen2009-03-111-2/+2
| | | | | | | | allocations. Apparently the assumption is there is an instruction (terminator?) following the allocation so I am allowing the same assumption. llvm-svn: 66716
* Removing a dead debug intrinsic shouldn't triggerDale Johannesen2009-03-101-3/+6
| | | | | | | another instcombine pass if we weren't going to make one without debug info. llvm-svn: 66576
* change the MemIntrinsic get/setAlignment method to take an unsignedChris Lattner2009-03-081-5/+5
| | | | | | instead of a Constant*, which is what the clients of it really want. llvm-svn: 66364
* Introduce a new MemTransferInst pseudo class, which is a commonChris Lattner2009-03-081-1/+1
| | | | | | | parent between MemCpyInst and MemMoveInst, simplify some code to use it. llvm-svn: 66361
* Fix another case where debug info was affectingDale Johannesen2009-03-051-4/+17
| | | | | | | codegen. I convinced myself it was OK to skip all pointer bitcasts here too. llvm-svn: 66122
* Fix another case where a dbg.declare meant somethingDale Johannesen2009-03-051-6/+13
| | | | | | had 2 uses instead of 1. llvm-svn: 66112
* Always skip ptr-to-ptr bitcasts when counting,Dale Johannesen2009-03-041-5/+5
| | | | | | per Chris' suggestion. Slightly faster. llvm-svn: 65999
* Make my earlier patch to skip debug intrinsicsDale Johannesen2009-03-041-2/+1
| | | | | | when counting work; it was only off by 1. llvm-svn: 65993
* Instruction counters must skip the bitcasts thatDale Johannesen2009-03-031-1/+5
| | | | | | | feed into llvm.dbg.declare nodes, as well as the debug directives themselves. llvm-svn: 65976
* When removing a store to an alloca that has only oneDale Johannesen2009-03-031-10/+48
| | | | | | | | use, check also for the case where it has two uses, the other being a llvm.dbg.declare. This is needed so debug info doesn't affect codegen. llvm-svn: 65970
* Fix a bunch of Doxygen syntax issues. Escape special characters,Dan Gohman2009-03-031-2/+2
| | | | | | and put @file directives on their own comment line. llvm-svn: 65920
* Don't count DebugInfo instructions in another limitDale Johannesen2009-03-031-1/+7
| | | | | | (lest they affect codegen). llvm-svn: 65915
* When sinking an insn in InstCombine bring its debugDale Johannesen2009-03-031-0/+1
| | | | | | | | info with it. Don't count debug info insns against the scan maximum in FindAvailableLoadedValue (lest they affect codegen). llvm-svn: 65910
* Fix PR3694: add an instcombine micro-optimization that helpsDuncan Sands2009-03-021-5/+17
| | | | | | clean up when using variable length arrays in llvm-gcc. llvm-svn: 65832
* Silence compiler warning about use of uninitialized variables (in reality theseNick Lewycky2009-02-271-1/+1
| | | | | | are always set by reference on the path that uses them.) No functional change. llvm-svn: 65621
* Fix PR3667Chris Lattner2009-02-251-1/+1
| | | | llvm-svn: 65464
* Fix a ValueTracking rule: RHS means operand 1, not 0. Add a simpleDan Gohman2009-02-241-1/+6
| | | | | | | ashr instcombine to help expose this code. And apply the fix to SelectionDAG's copy of this code too. llvm-svn: 65364
* Should reset DBI_Prev if DBI_Next == 0.Zhou Sheng2009-02-231-0/+2
| | | | llvm-svn: 65314
* fix some typos that Duncan noticedChris Lattner2009-02-231-3/+3
| | | | llvm-svn: 65306
* Revert the part of 64623 that attempted to align the source in aDan Gohman2009-02-221-1/+1
| | | | | | | | | | | | | | | memcpy to match the alignment of the destination. It isn't necessary for making loads and stores handled like the SSE loadu/storeu intrinsics, and it was causing a performance regression in MultiSource/Applications/JM/lencod. The problem appears to have been a memcpy that copies from some highly aligned array into an alloca; the alloca was then being assigned a large alignment, which required codegen to perform dynamic stack-pointer re-alignment, which forced the enclosing function to have a frame pointer, which led to increased spilling. llvm-svn: 65289
* Don't sign extend the char when expanding char -> int duringNick Lewycky2009-02-211-2/+2
| | | | | | load(bitcast(char[4] to i32*)) evaluation. llvm-svn: 65246
* rename a function to indicate that it checks for profitability as wellChris Lattner2009-02-211-9/+36
| | | | | | | | as legality. Make load sinking and gep sinking more careful: we only do it when it won't pessimize loads from the stack. This has the added benefit of not producing code that is unanalyzable to SROA. llvm-svn: 65209
* commit a tweaked version of Daniel's patch for PR3599. We nowChris Lattner2009-02-171-26/+29
| | | | | | | eliminate all the extensions and all but the one required truncate from the testcase, but the or/and/shift stuff still isn't zapped. llvm-svn: 64809
* Fix EnforceKnownAlignment so that it doesn't ever reduce the alignmentDan Gohman2009-02-161-4/+12
| | | | | | of an alloca or global variable. llvm-svn: 64693
* Change these tests to use regular loads instead of llvm.x86.sse2.loadu.dq.Dan Gohman2009-02-161-3/+5
| | | | | | | | Enhance instcombine to use the preferred field of GetOrEnforceKnownAlignment in more cases, so that regular IR operations are optimized in the same way that the intrinsics currently are. llvm-svn: 64623
* the two non-mask arguments to a shufflevector must be the same width, but ↵Nate Begeman2009-02-111-3/+4
| | | | | | | | they do not have to be the same width as the result value. llvm-svn: 64335
* Instrcombine should not change load(cast p) to cast(load p) if the castMon P Wang2009-02-071-1/+7
| | | | | | changes the address space of the pointer. llvm-svn: 64035
* APInt'fy SimplifyDemandedVectorElts so it can analyze vectors with more than ↵Evan Cheng2009-02-031-49/+54
| | | | | | 64 elements. llvm-svn: 63631
* reduce indentation, (~XorCST->getValue()).isSignBit() -> isMaxSignedValue()Chris Lattner2009-02-021-20/+19
| | | | llvm-svn: 63500
* Reinstate this optimization to fold icmp of xor when possible. Don't try toNick Lewycky2009-01-311-5/+50
| | | | | | | turn icmp eq a+x, b+x into icmp eq a, b if a+x or b+x has other uses. This may have been increasing register pressure leading to the bzip2 slowdown. llvm-svn: 63487
* Fix PR3452 (an infinite loop bootstrapping) by disabling the recentChris Lattner2009-01-311-10/+12
| | | | | | | | | | | improvements to the EvaluateInDifferentType code. This code works by just inserted a bunch of new code and then seeing if it is useful. Instcombine is not allowed to do this: it can only insert new code if it is useful, and only when it is converging to a more canonical fixed point. Now that we iterate when DCE makes progress, this causes an infinite loop when the code ends up not being used. llvm-svn: 63483
* now that all the pieces are in place, teach instcombine'sChris Lattner2009-01-311-2/+58
| | | | | | | | | | | | | | simplifydemandedbits to simplify instructions with *multiple uses* in contexts where it can get away with it. This allows it to simplify the code in multi-use-or.ll into a single 'add double'. This change is particularly interesting because it will cover up for some common codegen bugs with large integers created due to the recent SROA patch. When working on fixing those bugs, this should be disabled. llvm-svn: 63481
* simplify/clarify control flow and improve comments, no functionality change.Chris Lattner2009-01-311-13/+21
| | | | llvm-svn: 63480
* make some fairly meaty internal changes to how SimplifyDemandedBits works.Chris Lattner2009-01-311-206/+172
| | | | | | | | | | | | | Now, if it detects that "V" is the same as some other value, SimplifyDemandedBits returns the new value instead of RAUW'ing it immediately. This has two benefits: 1) simpler code in the recursive SimplifyDemandedBits routine. 2) it allows future fun stuff in instcombine where an operation has multiple uses and can be simplified in one context, but not all. #2 isn't implemented yet, this patch should have no functionality change. llvm-svn: 63479
* minor cleanupsChris Lattner2009-01-311-3/+3
| | | | llvm-svn: 63477
* make sure to set Changed=true when instcombine hacks on the code,Chris Lattner2009-01-311-5/+9
| | | | | | | not doing so prevents it from properly iterating and prevents it from deleting the entire body of dce-iterate.ll llvm-svn: 63476
* Fixed optimization of combining two shuffles where the first shuffle inputsMon P Wang2009-01-261-1/+3
| | | | | | has a different number of elements than the output. llvm-svn: 62998
OpenPOWER on IntegriCloud