summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't make TwoToExp signed by default.Bill Wendling2008-11-301-2/+1
| | | | llvm-svn: 60279
* From Hacker's Delight:Bill Wendling2008-11-301-8/+10
| | | | | | | | | | "For signed integers, the determination of overflow of x*y is not so simple. If x and y have the same sign, then overflow occurs iff xy > 2**31 - 1. If they have opposite signs, then overflow occurs iff xy < -2**31." In this case, x == -1. llvm-svn: 60278
* Instcombine was illegally transforming -X/C into X/-C when either X or CBill Wendling2008-11-301-3/+20
| | | | | | | | overflowed on negation. This commit checks to make sure that neithe C nor X overflows. This requires that the RHS of X (a subtract instruction) be a constant integer. llvm-svn: 60275
* Chris prefers icmp/select over udiv!Nick Lewycky2008-11-271-3/+11
| | | | llvm-svn: 60187
* Add a couple of missed optimizations on integer vectors. Multiply and divideNick Lewycky2008-11-271-6/+22
| | | | | | by 1, as well as multiply by -1. llvm-svn: 60182
* switch InstCombine::visitLoadInst to use Chris Lattner2008-11-271-43/+29
| | | | | | FindAvailableLoadedValue llvm-svn: 60169
* reapply Sanjiv's patch to genericize memcpy/memset/memmove to take anChris Lattner2008-11-211-6/+5
| | | | | | arbitrary integer width for the count. llvm-svn: 59823
* Revert r59802. It was breaking the build of llvm-gcc:Bill Wendling2008-11-211-5/+6
| | | | | | | | | | | | | | | | | | | | | g++ -m32 -c -g -DIN_GCC -W -Wall -Wwrite-strings -Wmissing-format-attribute -fno-common -mdynamic-no-pic -DHAVE_CONFIG_H -Wno-unused -DTARGET_NAME=\"i386-apple-darwin9.5.0\" -I. -I. -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/. -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include -DENABLE_LLVM -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/../llvm.src/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I. -I. -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/. -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include ../../llvm-gcc.src/gcc/llvm-types.cpp -o llvm-types.o ../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemCpy(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)': ../../llvm-gcc.src/gcc/llvm-convert.cpp:1496: error: 'memcpy_i32' is not a member of 'llvm::Intrinsic' ../../llvm-gcc.src/gcc/llvm-convert.cpp:1496: error: 'memcpy_i64' is not a member of 'llvm::Intrinsic' ../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemMove(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)': ../../llvm-gcc.src/gcc/llvm-convert.cpp:1512: error: 'memmove_i32' is not a member of 'llvm::Intrinsic' ../../llvm-gcc.src/gcc/llvm-convert.cpp:1512: error: 'memmove_i64' is not a member of 'llvm::Intrinsic' ../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemSet(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)': ../../llvm-gcc.src/gcc/llvm-convert.cpp:1528: error: 'memset_i32' is not a member of 'llvm::Intrinsic' ../../llvm-gcc.src/gcc/llvm-convert.cpp:1528: error: 'memset_i64' is not a member of 'llvm::Intrinsic' make[3]: *** [llvm-convert.o] Error 1 make[3]: *** Waiting for unfinished jobs.... rm fsf-funding.pod gcov.pod gfdl.pod cpp.pod gpl.pod gcc.pod make[2]: *** [all-stage1-gcc] Error 2 make[1]: *** [stage1-bubble] Error 2 make: *** [all] Error 2 llvm-svn: 59809
* Make mem[cpy,move,set] intrinsics overloaded.Sanjiv Gupta2008-11-211-6/+5
| | | | llvm-svn: 59802
* Optimize (x/y)*y into x-(x%y) in general. Div and rem are about the same, andNick Lewycky2008-11-211-11/+34
| | | | | | a subtract is cheaper than a multiply. This generalizes an existing transform. llvm-svn: 59800
* If there are two consecutive llvm.dbg.stoppoint calls thenDevang Patel2008-11-191-1/+16
| | | | | | | it is likely that the optimizer deleted code in between these two intrinsics. Keep only the last llvm.dbg.stoppoint in this case. llvm-svn: 59657
* simplify a bunch more instcombines to use m_Specific etc.Chris Lattner2008-11-161-40/+37
| | | | llvm-svn: 59403
* factor the code for simplifying (icmp)|(icmp) into its own function.Chris Lattner2008-11-161-151/+167
| | | | llvm-svn: 59402
* do some computation with apints instead of ConstantInts.Chris Lattner2008-11-161-6/+5
| | | | llvm-svn: 59401
* merge a check into a place where it is simpler.Chris Lattner2008-11-161-20/+17
| | | | llvm-svn: 59400
* factor a whole bunch of code out into a helper function.Chris Lattner2008-11-161-149/+166
| | | | llvm-svn: 59398
* simplify the conditions on two gigantic if's, decreasing indentationChris Lattner2008-11-161-290/+289
| | | | | | a bit. Next step is to factor out into their own helper functions. llvm-svn: 59397
* simplify some instcombine matches by using m_SpecificChris Lattner2008-11-161-37/+34
| | | | llvm-svn: 59395
* Use new m_SelectCst template to eliminate macros.Chris Lattner2008-11-161-9/+5
| | | | llvm-svn: 59392
* simplify code.Chris Lattner2008-11-161-17/+12
| | | | llvm-svn: 59390
* Handle the case where there is no "not". It is possible it got Chris Lattner2008-11-161-0/+4
| | | | | | folded into the select. llvm-svn: 59389
* factor a bunch of copy/paste code out into a helper function.Chris Lattner2008-11-161-61/+35
| | | | | | | Eliminate the cases checking for cond?0:-1, since that is already handled by commutative checking. llvm-svn: 59388
* rearrange some code, no functionality change.Chris Lattner2008-11-161-21/+21
| | | | llvm-svn: 59381
* if we're going to use a macro, use it maximally. no functionality change.Chris Lattner2008-11-161-8/+8
| | | | llvm-svn: 59380
* Third time's a charm.Bill Wendling2008-11-101-60/+58
| | | | | | | The previous patches didn't match correctly. Also, we need to make sure that the conditional is the same before doing the transformation. llvm-svn: 58978
* Added support for the following definition of shufflevector Mon P Wang2008-11-101-17/+30
| | | | | | <result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask> llvm-svn: 58964
* Correction for the last patch. Should match the conditional in the first partBill Wendling2008-11-091-34/+42
| | | | | | of the select match, not the select instruction itself. llvm-svn: 58947
* The method of doing the matching with a 'select' instruction was wrong. TheBill Wendling2008-11-091-32/+39
| | | | | | | | | | | | | | | | | | original code was matching like this: if (match(A, m_Not(m_Value(B)))) B was already matched as a 'select' instruction. However, this isn't matching what we think it's matching. It would match B as a 'Value', so basically anything would match to it. In this case, a Constant matched. B was replaced with a constant representation. And then the wrong value would be used in the SelectInst::Create statement, causing a crash. After thinking on this for a moment, and after Nick L. told me how the pattern matching stuff was supposed to work, the solution was to match NOT an m_Value, but an m_Select. llvm-svn: 58946
* If the LHS of the FCMP is coming from a UIToFP instruction, then we don't wantBill Wendling2008-11-091-33/+88
| | | | | | | | | | | | | | | | | | | | | | | to generate signed ICMP instructions to replace the FCMP. This would violate the following: define i1 @test1(i32 %val) { %1 = uitofp i32 %val to double %2 = fcmp ole double %1, 0.000000e+00 ret i1 %2 } would be transformed into: define i1 @test1(i32 %val) { %1 = icmp slt i33 %val, 1 ret i1 %1 } which is obviously wrong. This patch modifes InstCombiner::FoldFCmp_IntToFP_Cst to handle when the LHS comes from UIToFP. llvm-svn: 58929
* Fixed scalarizing an extract subvector and prevent an infinite loopMon P Wang2008-11-061-0/+6
| | | | | | when simplify a vector. llvm-svn: 58820
* Fix demanded bits analysis with srem by negative number. Based on a patchNick Lewycky2008-11-021-3/+3
| | | | | | by Richard Osborne. llvm-svn: 58555
* Fix this recently moved code to use the correct type. CI is now aDan Gohman2008-11-021-2/+2
| | | | | | | ConstantInt, and SI is the original cast instruction. This fixes PR2996. llvm-svn: 58549
* Canonicalize sext(i1) to i1?-1:0, and update various instcombineDan Gohman2008-10-301-40/+91
| | | | | | optimizations accordingly. llvm-svn: 58457
* (A & sext(C)) | (B & ~sext(C) -> C ? A : BDan Gohman2008-10-281-0/+19
| | | | llvm-svn: 58351
* Teach instcombine's visitLoad to scan back several instructionsDan Gohman2008-10-151-10/+46
| | | | | | | | | | | | | | to find opportunities for store-to-load forwarding or load CSE, in the same way that visitStore scans back to do DSE. Also, define a new helper function for testing whether the addresses of two memory accesses are known to have the same value, and use it in both visitStore and visitLoad. These two changes allow instcombine to eliminate loads in code produced by front-ends that frequently emit obviously redundant addressing for memory references. llvm-svn: 57608
* Combine (fcmp cc0 x, y) | (fcmp cc1 x, y) into a single fcmp when possible.Evan Cheng2008-10-141-1/+41
| | | | llvm-svn: 57515
* - Somehow I forgot about one / une.Evan Cheng2008-10-141-9/+21
| | | | | | | - Renumber fcmp predicates to match their icmp counterparts. - Try swapping operands to expose more optimization opportunities. llvm-svn: 57513
* Optimize anding of two fcmp into a single fcmp if the operands are the same. ↵Evan Cheng2008-10-141-3/+111
| | | | | | | | | e.g. uno && ueq -> ueq ord && olt -> olt ord && ueq -> oeq llvm-svn: 57507
* Make InstructionCombining::getBitCastOperand() recognize GEP instructions andMatthijs Kooijman2008-10-131-3/+23
| | | | | | constant expression with all zero indices as being the same as a bitcast. llvm-svn: 57442
* Fix PR2697 by rewriting the '(X / pos) op neg' logic. This also changesChris Lattner2008-10-111-10/+15
| | | | | | | | a couple other cases for clarity, but shouldn't affect correctness. Patch by Eli Friedman! llvm-svn: 57387
* Add a "loses information" return value to APFloat::convertDale Johannesen2008-10-091-1/+3
| | | | | | | and APFloat::convertToInteger. Restore return value to IEEE754. Adjust all users accordingly. llvm-svn: 57329
* Add parentheses to avoid warnings in GCC 4.4.0,Chris Lattner2008-10-081-1/+1
| | | | | | patch by Samuel Tardieu! llvm-svn: 57288
* rewrite bswap matching to be more general, allowing arbitraryChris Lattner2008-10-051-77/+121
| | | | | | | | shifting and masking inside a bswap expr. This allows it to handle the cases from PR2842, which involve the intermediate 'or' expressions being shifted, not just the input value. llvm-svn: 57095
* fix a bug where the bswap matcher could match a case involvingChris Lattner2008-10-051-1/+4
| | | | | | ashr. It should only apply to lshr. llvm-svn: 57089
* Factorize code: remove variants of "strip offDuncan Sands2008-10-011-23/+1
| | | | | | | | | | | pointer bitcasts and GEP's", and centralize the logic in Value::getUnderlyingObject. The difference with stripPointerCasts is that stripPointerCasts only strips GEPs if all indices are zero, while getUnderlyingObject strips GEPs no matter what the indices are. llvm-svn: 56922
* Fix misoptimization of: xor i1 (icmp eq (X, C1), icmp s[lg]t (X, C2))Nick Lewycky2008-09-301-2/+3
| | | | llvm-svn: 56834
* Now Attributes are divided in three groupsDevang Patel2008-09-261-9/+17
| | | | | | | | | | | | | - return attributes - inreg, zext and sext - parameter attributes - function attributes - nounwind, readonly, readnone, noreturn Return attributes use 0 as the index. Function attributes use ~0U as the index. This patch requires corresponding changes in llvm-gcc and clang. llvm-svn: 56704
* Large mechanical patch.Devang Patel2008-09-251-32/+32
| | | | | | | | | | | | | | | s/ParamAttr/Attribute/g s/PAList/AttrList/g s/FnAttributeWithIndex/AttributeWithIndex/g s/FnAttr/Attribute/g This sets the stage - to implement function notes as function attributes and - to distinguish between function attributes and return value attributes. This requires corresponding changes in llvm-gcc and clang. llvm-svn: 56622
* s/ParamAttrsWithIndex/FnAttributeWithIndex/gDevang Patel2008-09-241-8/+8
| | | | llvm-svn: 56535
* s/ParameterAttributes/Attributes/gDevang Patel2008-09-231-8/+8
| | | | llvm-svn: 56513
OpenPOWER on IntegriCloud