summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
Commit message (Collapse)AuthorAgeFilesLines
* add is always integer, thanks to Frits for noticing this.Chris Lattner2011-02-171-1/+1
| | | | llvm-svn: 125774
* preserve NUW/NSW when transforming add x,xChris Lattner2011-02-171-2/+7
| | | | llvm-svn: 125711
* When lowering an inbounds gep, the intermediate adds can haveChris Lattner2011-02-111-6/+3
| | | | | | | | unsigned overflow (e.g. due to a negative array index), but the scales on array size multiplications are known to not sign wrap. llvm-svn: 125409
* implement the first part of PR8882: when lowering an inboundsChris Lattner2011-02-101-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | gep to explicit addressing, we know that none of the intermediate computation overflows. This could use review: it seems that the shifts certainly wouldn't overflow, but could the intermediate adds overflow if there is a negative index? Previously the testcase would instcombine to: define i1 @test(i64 %i) { %p1.idx.mask = and i64 %i, 4611686018427387903 %cmp = icmp eq i64 %p1.idx.mask, 1000 ret i1 %cmp } now we get: define i1 @test(i64 %i) { %cmp = icmp eq i64 %i, 1000 ret i1 %cmp } llvm-svn: 125271
* A bunch of cleanups and simplifications using the new PatternMatch predicatesChris Lattner2011-02-101-176/+132
| | | | | | | | | | and generally tidying things up. Only very trivial functionality changes like now doing (-1 - A) -> (~A) for vectors too. InstCombineAddSub.cpp | 296 +++++++++++++++++++++----------------------------- 1 file changed, 126 insertions(+), 170 deletions(-) llvm-svn: 125264
* one more instcombine variant that is needed to work with future changes,Chris Lattner2011-01-151-0/+9
| | | | | | no functionality change currently. llvm-svn: 123517
* Add a generic expansion transform: A op (B op' C) -> (A op B) op' (A op C)Duncan Sands2010-12-221-6/+8
| | | | | | | | if both A op B and A op C simplify. This fires fairly often but doesn't make that much difference. On gcc-as-one-file it removes two "and"s and turns one branch into a select. llvm-svn: 122399
* Move Sub simplifications and additional Add simplifications out ofDuncan Sands2010-12-151-28/+4
| | | | | | instcombine and into InstructionSimplify. llvm-svn: 121861
* Rename SimplifyDistributed to the more meaningfull name SimplifyByFactorizing.Duncan Sands2010-11-231-2/+2
| | | | llvm-svn: 120051
* Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in aDuncan Sands2010-11-231-0/+5
| | | | | | | | | | | | fairly systematic way in instcombine. Some of these cases were already dealt with, in which case I removed the existing code. The case of Add has a bunch of funky logic which covers some of this plus a few variants (considers shifts to be a form of multiplication), which I didn't touch. The simplification performed is: A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and also to do it more often by not checking for "only one use" if "B+C" simplifies. llvm-svn: 120024
* InstCombine: Implement X - A*-B -> X + A*B.Benjamin Kramer2010-11-221-0/+9
| | | | llvm-svn: 119984
* Generalize the reassociation transform in SimplifyCommutative (now renamed toDuncan Sands2010-11-131-2/+2
| | | | | | | | | | | | | | | | SimplifyAssociativeOrCommutative) "(A op C1) op C2" -> "A op (C1 op C2)", which previously was only done if C1 and C2 were constants, to occur whenever "C1 op C2" simplifies (a la InstructionSimplify). Since the simplifying operand combination can no longer be assumed to be the right-hand terms, consider all of the possible permutations. When compiling "gcc as one big file", transform 2 (i.e. using right-hand operands) fires about 4000 times but it has to be said that most of the time the simplifying operands are both constants. Transforms 3, 4 and 5 each fired once. Transform 6, which is an existing transform that I didn't change, never fired. With this change, the testcase is now optimized perfectly with one run of instcombine (previously it required instcombine + reassociate + instcombine, and it may just have been luck that this worked). llvm-svn: 119002
* Floating-point add, sub, and mul are now spelled fadd, fsub, and fmul,Dan Gohman2010-03-021-3/+3
| | | | | | respectively. llvm-svn: 97531
* Uniformize the names of type predicates: rather than having isFloatTy andDuncan Sands2010-02-151-6/+6
| | | | | | isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris! llvm-svn: 96223
* Simplify/generalize the xor+add->sign-extend instcombine.Eli Friedman2010-01-311-35/+19
| | | | llvm-svn: 94943
* Add a small transform: transform -(X<<Y) to (-X<<Y) when the shift has a singleEli Friedman2010-01-311-0/+7
| | | | | | use and X is free to negate. llvm-svn: 94941
* When the visitSub method was split into visitSub and visitFSub, this xform wasBill Wendling2010-01-131-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | added to the FSub version. However, the original version of this xform guarded against doing this for floating point (!Op0->getType()->isFPOrFPVector()). This is causing LLVM to perform incorrect xforms for code like: void func(double *rhi, double *rlo, double xh, double xl, double yh, double yl){ double mh, ml; double c = 134217729.0; double up, u1, u2, vp, v1, v2; up = xh*c; u1 = (xh - up) + up; u2 = xh - u1; vp = yh*c; v1 = (yh - vp) + vp; v2 = yh - v1; mh = xh*yh; ml = (((u1*v1 - mh) + (u1*v2)) + (u2*v1)) + (u2*v2); ml += xh*yl + xl*yh; *rhi = mh + ml; *rlo = (mh - (*rhi)) + ml; } The last line was optimized away, but rl is intended to be the difference between the infinitely precise result of mh + ml and after it has been rounded to double precision. llvm-svn: 93369
* reduce indentationChris Lattner2010-01-051-15/+18
| | | | llvm-svn: 92766
* Convert a ton of simple integer type equality tests to the new predicate.Benjamin Kramer2010-01-051-2/+2
| | | | llvm-svn: 92760
* split add/sub out to its own file. Eliminate use ofChris Lattner2010-01-051-0/+748
dyn_castNotVal in the X+~X transform. dyn_castNotVal is dramatic overkill for what the xform needed. llvm-svn: 92704
OpenPOWER on IntegriCloud