summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify
Commit message (Collapse)AuthorAgeFilesLines
...
* Move InstCombine's knowledge of fdiv to SimplifyInstruction().Frits van Bommel2011-01-291-0/+17
| | | | llvm-svn: 124534
* Fix typo: should have been testing that X was odd, not V.Duncan Sands2011-01-291-0/+24
| | | | llvm-svn: 124533
* My auto-simplifier noticed that ((X/Y)*Y)/Y occurs several times in SPECDuncan Sands2011-01-281-0/+56
| | | | | | | | | | | | | | | | | benchmarks, and that it can be simplified to X/Y. (In general you can only simplify (Z*Y)/Y to Z if the multiplication did not overflow; if Z has the form "X/Y" then this is the case). This patch implements that transform and moves some Div logic out of instcombine and into InstructionSimplify. Unfortunately instcombine gets in the way somewhat, since it likes to change (X/Y)*Y into X-(X rem Y), so I had to teach instcombine about this too. Finally, thanks to the NSW/NUW flags, sometimes we know directly that "Z*Y" does not overflow, because the flag says so, so I added that logic too. This eliminates a bunch of divisions and subtractions in 447.dealII, and has good effects on some other benchmarks too. It seems to have quite an effect on tramp3d-v4 but it's hard to say if it's good or bad because inlining decisions changed, resulting in massive changes all over. llvm-svn: 124487
* In which I discover that zero+zero is zero, d'oh!Duncan Sands2011-01-251-1/+14
| | | | llvm-svn: 124188
* Turn off this test - the corresponding instsimplify logic has beenDuncan Sands2011-01-251-2/+0
| | | | | | disabled. llvm-svn: 124185
* According to my auto-simplifier the most common missed simplifications inDuncan Sands2011-01-251-0/+54
| | | | | | | | | | | optimized code are: (non-negative number)+(power-of-two) != 0 -> true and (x | 1) != 0 -> true Instcombine knows about the second one of course, but only does it if X|1 has only one use. These fire thousands of times in the testsuite. llvm-svn: 124183
* At -O123 the early-cse pass is run before instcombine has run. According to myDuncan Sands2011-01-201-0/+45
| | | | | | | | | | | | | | | | auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0. This patch adds this transform and some related logic to InstructionSimplify and removes some of the logic from instcombine (unfortunately not all because there are several situations in which instcombine can improve things by making new instructions, whereas instsimplify is not allowed to do this). At -O2 this often results in more than 15% more simplifications by early-cse, and results in hundreds of lines of bitcode being eliminated from the testsuite. I did see some small negative effects in the testsuite, for example a few additional instructions in three programs. One program, 483.xalancbmk, got an additional 35 instructions, which seems to be due to a function getting an additional instruction and then being inlined all over the place. llvm-svn: 123911
* For completeness, generalize the (X + Y) - Y -> X transform and add X - (X + ↵Duncan Sands2011-01-181-0/+20
| | | | | | | | | | 1) -> -1. These were not recommended by my auto-simplifier since they don't fire often enough. However they do fire from time to time, for example they remove one subtraction from the final bitcode for 483.xalancbmk. llvm-svn: 123755
* Simplify (X<<1)-X into X. According to my auto-simplier this is the most ↵Duncan Sands2011-01-181-0/+20
| | | | | | | | | | | | | common missed simplification in fully optimized code. It occurs sporadically in the testsuite, and many times in 403.gcc: the final bitcode has 131 fewer subtractions after this change. The reason that the multiplies are not eliminated is the same reason that instcombine did not catch this: they are used by other instructions (instcombine catches this with a more general transform which in general is only profitable if the operands have only one use). llvm-svn: 123754
* Turn X-(X-Y) into Y. According to my auto-simplifier this is the most commonDuncan Sands2011-01-141-0/+8
| | | | | | | | | simplification present in fully optimized code (I think instcombine fails to transform some of these when "X-Y" has more than one use). Fires here and there all over the test-suite, for example it eliminates 8 subtractions in the final IR for 445.gobmk, 2 subs in 447.dealII, 2 in paq8p etc. llvm-svn: 123442
* Factorize common code out of the InstructionSimplify shift logic. Add inDuncan Sands2011-01-141-0/+9
| | | | | | | | | | | threading of shifts over selects and phis while there. This fires here and there in the testsuite, to not much effect. For example when compiling spirit it fires 5 times, during early-cse, resulting in 6 more cse simplifications, and 3 more terminators being folded by jump threading, but the final bitcode doesn't change in any interesting way: other optimizations would have caught the opportunity anyway, only later. llvm-svn: 123441
* Rename this test.Duncan Sands2011-01-141-0/+0
| | | | llvm-svn: 123440
* The most common simplification missed by instsimplify in unoptimized bitcodeDuncan Sands2011-01-131-0/+7
| | | | | | | | is "X != 0 -> X" when X is a boolean. This occurs a lot because of the way llvm-gcc converts gcc's conditional expressions. Add this, and a few other similar transforms for completeness. llvm-svn: 123372
* Revert commit 122654 at the request of Chris, who reckons that instsimplifyDuncan Sands2011-01-011-9/+0
| | | | | | is the wrong hammer for this nail, and is probably right. llvm-svn: 122661
* Fix a README item by having InstructionSimplify do a mild form of valueDuncan Sands2011-01-011-0/+9
| | | | | | | | | | | numbering, in which it considers (for example) "%a = add i32 %x, %y" and "%b = add i32 %x, %y" to be equal because the operands are equal and the result of the instructions only depends on the values of the operands. This has almost no effect (it removes 4 instructions from gcc-as-one-file), and perhaps slows down compilation: I measured a 0.4% slowdown on the large gcc-as-one-file testcase, but it wasn't statistically significant. llvm-svn: 122654
* When determining whether the new instruction was already present inDuncan Sands2010-12-221-0/+11
| | | | | | | | the original instruction, half the cases were missed (making it not wrong but suboptimal). Also correct a typo (A <-> B) in the second chunk. llvm-svn: 122414
* Add an additional InstructionSimplify factorization test.Duncan Sands2010-12-211-0/+10
| | | | llvm-svn: 122333
* While I don't think any later transforms can fire, it seems cleaner toDuncan Sands2010-12-211-0/+22
| | | | | | | not assume this (for example in case more transforms get added below it). Suggested by Frits van Bommel. llvm-svn: 122332
* Fix typo in comment, spotted by Deewiant.Duncan Sands2010-12-211-1/+1
| | | | llvm-svn: 122329
* Teach InstructionSimplify about distributive laws. These transforms fireDuncan Sands2010-12-211-0/+21
| | | | | | | quite often, but don't make much difference in practice presumably because instcombine also knows them and more. llvm-svn: 122328
* Add generic simplification of associative operations, generalizingDuncan Sands2010-12-212-0/+67
a couple of existing transforms. This fires surprisingly often, for example when compiling gcc "(X+(-1))+1->X" fires quite a lot as well as various "and" simplifications (usually with a phi node operand). Most of the time this doesn't make a real difference since the same thing would have been done elsewhere anyway, eg: by instcombine, but there are a few places where this results in simplifications that we were not doing before. llvm-svn: 122326
OpenPOWER on IntegriCloud