summaryrefslogtreecommitdiff
path: root/compiler/optimizing/constant_folding.h
AgeCommit message (Collapse)Author
2024-01-15Revert "Restrict the use of ConstantFolding's VisitIf" Santiago Aboy Solanes
This reverts commit 5eb1fd0dae3832ceee2102613bb08c291daca6f3. Reason for revert: In aosp/2903248 we implemented a faster way of doing `ReplaceUsesDominatedBy` which is used by `VisitIf`. The impact of `VisitIf` is now small enough that running VisitIf in all passes is faster that the previous implementation running some of the time. This CLs re-enables the optimization in all constant folding passes because: A) Lets this optimization (and others that can use the result) kick in earlier B) Run it for callee graphs in the inliner (which has been disabled as of CL aosp/2543831) C) Consistency of the ConstantFolding pass, which helps to have a simpler mental model Bug: 278626992 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: Locally compiled GMS and compared time to compile Change-Id: I5dc5f591557c8de0bc4d23dbfd0b91b5b7e56ab5
2023-04-19Restrict the use of ConstantFolding's VisitIf Santiago Aboy Solanes
It was taking a lot of time for the improvement it got. We can get 99.99% of the improvement, with only one VisitIf call. This is roughly 20% of the compile time it used to take. Bug: 278626992 Fixes: 278626992 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Icc00c9ad6a9eb4f4fd18677bcb65655cbbe9d027
2023-04-03Optimize String's length/isEmpty for constant strings Santiago Aboy Solanes
If at compile time we know the length of the string, we can insert that constant into the graph. As part of this CL, I introduced VisitArrayLength in ConstantFolding. This is done because: * We are folding the instrucion into a constant so it makes logical sense, and * It plays better with isEmpty since that's an ArrayLength+Equal which can be dealt with in one ConstantFolding pass. As a note, there's VisitArrayLength in InstructionSimplifier which would make sense to also move to ConstantFolding. However, in doing so we get code size regressions. Added a TODO to see if we can deal with that in the future. Locally speed-compiling in a Pixel 5: * SystemServer: -4.38 KB (-0.01%) * SystemUIGoogle: -23.92KB (-0.09%) * AGSA: -217.66KB (-0.07%) Bug: 276416001 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Ic2081d489482157b016762e0ec103319d3b9a46e
2022-11-07Reland "Make compiler/optimizing/ symbols hidden." VladimĂ­r Marko
This reverts commit 0a51605ddd81635135463dab08b6f7c21b58ffb0. Reason for revert: Reland after some of the required work was merged in other CLs. Also address a TODO from the original CL to mark required symbols with EXPORT in `intrinsic_objects.h`. Also mark symbols in new files as HIDDEN. Bug: 186902856 Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I936d448983928af23614ca82c2d0bf9a645e2c52
2022-08-17Reland "Propagating values from if clauses to its successors" Santiago Aboy Solanes
This reverts commit fa1034c563b44c4f557814c50e2678e14dcd1d13. Reason for revert: Relanding after float/double fix. In short, don't deal with floats/doubles since they bring a lot of edge cases e.g. if (f == 0.0f) { // f is not guaranteed to be 0.0f, e.g. it could be -0.0f. } Bug: 240543764 Change-Id: I400bdab71dba0934e6f1740538fe6e6c0a7bf5fc
2022-08-09Revert "Propagating values from if clauses to its successors" Santiago Aboy Solanes
This reverts commit c6b816ceb2b35300c937ef2e7d008598b6afba21. Reason for revert: Broke libcore test https://ci.chromium.org/ui/p/art/builders/ci/angler-armv7-ndebug/3179/overview Change-Id: I4f238bd20cc485e49078104e0225c373cac23415
2022-08-09Propagating values from if clauses to its successors Santiago Aboy Solanes
We have knowledge of the value of some variables at compile time due to the fact they are used in if clauses. For example: if (variable == constant) { // SSA `variable` guaranteed to be equal to constant here. } else { // No guarantees can be made here (except for booleans since // they only have two values). } Similarly with `variable != constant`. We can also apply this to boolean parameters e.g. void foo (boolean val) { if (val) { // `val` guaranteed to be true here. ... } ... } Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I55df0252d672870993d06e5ac92f5bba44d902bd
2019-10-14Revert "Make compiler/optimizing/ symbols hidden." Vladimir Marko
This reverts commit e2727154f25e0db9a5bb92af494d8e47b181dfcf. Reason for revert: Breaks ASAN tests (ODR violation). Bug: 142365358 Change-Id: I38103d74a1297256c81d90872b6902ff1e9ef7a4
2019-10-14Make compiler/optimizing/ symbols hidden. Vladimir Marko
Make symbols in compiler/optimizing hidden by a namespace attribute. The unit intrinsic_objects.{h,cc} is excluded as it is needed by dex2oat. As the symbols are no longer exported, gtests are now linked with the static version of the libartd-compiler library. libart-compiler.so size: - before: arm: 2396152 arm64: 3345280 - after: arm: 2016176 (-371KiB, -15.9%) arm64: 2874480 (-460KiB, -14.1%) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Bug: 142365358 Change-Id: I1fb04a33351f53f00b389a1642e81a68e40912a8
2018-08-28Use 'final' and 'override' specifiers directly in ART. Roland Levillain
Remove all uses of macros 'FINAL' and 'OVERRIDE' and replace them with 'final' and 'override' specifiers. Remove all definitions of these macros as well, which were located in these files: - libartbase/base/macros.h - test/913-heaps/heaps.cc - test/ti-agent/ti_macros.h ART is now using C++14; the 'final' and 'override' specifiers have been introduced in C++11. Test: mmma art Change-Id: I256c7758155a71a2940ef2574925a44076feeebf
2018-04-26Step 1 of 2: conditional passes. Aart Bik
Rationale: The change adds a return value to Run() in preparation of conditional pass execution. The value returned by Run() is best effort, returning false means no optimizations were applied or no useful information was obtained. I filled in a few cases with more exact information, others still just return true. In addition, it integrates inlining as a regular pass, avoiding the ugly "break" into optimizations1 and optimziations2. Bug: b/78171933, b/74026074 Test: test-art-host,target Change-Id: Ia39c5c83c01dcd79841e4b623917d61c754cf075
2016-11-08ART: Fix tidy warnings Andreas Gampe
Switch to char versions of find variants. Add "explicit" constructor variants or refactor and remove defaults. Use const references. Bug: 32619234 Test: m test-art-host Change-Id: I970cc2f47d6cf8f0c74104b994b075b2fafb3d45
2016-02-18Merge "Add statistics support for some optimizations" Calin Juravle
2016-02-18Add statistics support for some optimizations Jean-Philippe Halimi
This patch adds support for the --dump-stats facility with some optimizations and fixes all build issues introduced by the patch: I68751b119a030952a11057cb651a3c63e87e73ea (which got reverted) Change-Id: I5af1f2a8cced0a1a55c2bb4d8c88e6f0a24ec879 Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
2016-02-17Implement Optimizing's constant folding as a visitor. Roland Levillain
Refactor the logic of art::HConstantFolding::Run into a new visitor, art::HConstantFoldingVisitor. Change-Id: Id8d3c3826f6dff6cc2d18a01f6c48d79bde483b3
2015-11-23Revert "Add stats support for existing optimizations" Nicolas Geoffray
Breaks the build. Please ensure your changes build. This reverts commit 06241b1b07fb031b7d2cf55f4b78d3444d07cc2d. Change-Id: I68b18f99a9882719bf6654d3313531a7965b8483
2015-11-22Add stats support for existing optimizations Jean-Philippe Halimi
This patch adds support for the --dump-stats facility with existing optimizations. Change-Id: I68751b119a030952a11057cb651a3c63e87e73ea Signed-off-by: Jean-Philippe Halimi <jean-philippe.halimi@intel.com>
2015-06-24ART: Run GraphChecker after Builder and SsaBuilder David Brazdil
This patch refactors the way GraphChecker is invoked, utilizing the same scoping mechanism as pass timing and graph visualizer. Therefore, GraphChecker will now run not just after instances of HOptimization but after the builders and reg alloc, too. Change-Id: I8173b98b79afa95e1fcbf3ac9630a873d7f6c1d4
2015-04-20Minor improvements to 458-checker-instruction-simplification. Alexandre Rames
This follows earlier comments from Roland: https://android-review.googlesource.com/#/c/140446 /2/test/458-checker-instruction-simplification/src/Main.java@337 /2/test/458-checker-instruction-simplification/src/Main.java@465 Change-Id: I255ab74b8885dd8e86bb2c11bba4075fa0eaa183
2014-11-19Use HOptimization abstraction for running optimizations. Nicolas Geoffray
Move existing optimizations to it. Change-Id: I3b43f9997faf4ed8875162e3a3abdf99375478dd
2014-10-17Revert "Revert "Introduce a class to implement optimization passes."" Roland Levillain
This reverts commit 1ddbf6d4b37979a9f11a203c12befd5ae8b65df4. Change-Id: I110a14668d1564ee0604dc958b91394b40da89fc
2014-10-01Revert "Introduce a class to implement optimization passes." Nicolas Geoffray
This reverts commit bf9cd7ba2118a75f5aa9b56241c4d5fa00dedeb8. Change-Id: I0a483446666c9c24c45925a5fc199debdefd8b3e
2014-10-01Introduce a class to implement optimization passes. Roland Levillain
- Add art::HOptimization. - Rename art::ConstantPropagation to art::HConstantFolding in compiler/optimizing/constant_folding.h to avoid name clashes with a class of the same name in compiler/dex/post_opt_passes.h. - Rename art::DeadCodeElimination to art::HDeadCodeElimination for consistency reasons. - Have art::HDeadCodeElimination and art::HConstantFolding derive from art::HOptimization. - Start to use these optimizations in art:OptimizingCompiler::TryCompile. Change-Id: Iaab350c122d87b2333b3760312b15c0592d7e010