summaryrefslogtreecommitdiff
path: root/compiler/optimizing/select_generator.cc
AgeCommit message (Collapse)Author
2025-01-17Optimizing: Rename `HSelectGenerator`... Vladimir Marko
... to `HCodeFlowSimplifier` in preparation for adding more optimizations to this pass. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Icb05c3455d93a7b939f82ced9b08165e533bb21a
2024-10-30cleanup FixUpInstructionType Santiago Aboy Solanes
It was expecting to have an HSelect as an input, so we might as well encode that with the C++ types. Rename it to FixUpSelectType. Also move the instructions around so that the ScopedObjectAccess scope is smaller. As a drive-by, move ScopedObjectAccess to CheckAgainstUpperBound so that we only call it in a subset of cases. Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing Change-Id: Id6f179e68e0a460577d5e42b8c431f3d035405a4
2023-04-27Optimizing: Add `HInstruction::As##type()`. Vladimir Marko
After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e
2023-04-27Optimizing: Rename `As##type` to `As##type##OrNull`. Vladimir Marko
The null type check in the current implementation of `HInstruction::As##type()` often cannot be optimized away by clang++. It is therefore beneficial to have two functions HInstruction::As##type() HInstruction::As##type##OrNull() where the first function never returns null but the second one can return null. The additional text "OrNull" shall also flag the possibility of yielding null to the developer which may help avoid bugs similar to what we have seen previously. This requires renaming the existing function that can return null and introducing new function that cannot. However, defining the new function `HInstruction::As##type()` in the same change as renaming the old one would risk introducing bugs by missing a rename. Therefore we simply rename the old function here and the new function shall be introduced in a separate change with all behavioral changes being explicit. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: buildbot-build.sh --target Bug: 181943478 Change-Id: I4defd85038e28fe3506903ba3f33f723682b3298
2023-04-26Remove unnecessary `HInstruction::As##type()` calls. Vladimir Marko
Also so some style cleanup. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I34304acb39bc5197dde03543a6c157b3c319f94f
2023-02-22Set more RTI only if they are valid Santiago Aboy Solanes
Follow-up to aosp/2442280. We haven't seen crashes with these ones, but we can't guarantee that the RTI will be valid in these code paths. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I80da85a6549ba0275a80027016363e0cf9fb8045
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-09-09Remove restriction of different Phi values in SelectGenerator Santiago Aboy Solanes
The restriction was blocking select generation and there's no good reason to have it. Also took the opportunity to create a robust test suite for select generation. Bug: 245535393 Test: dex2oat compiling the app in the bug Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I4d520a0210179ffa05c4536b3936bc3a67990935
2022-08-09Generate selects for nested ternary operators Santiago Aboy Solanes
After an R8 update, the generated dex instructions are different which means that the structure of the graph is different and we weren't recognizing a possibility of select generation. We now recognize it and can update the graph on the fly, generating the corresponding selects. Bug: 239385201 Fixes: 239385201 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: I07644f0a69369e809994b4dd39bdd95c2cc7dc6c
2020-05-13Move HandleCache to HGraph. Vladimir Marko
This avoids passing the `VariableSizedHandleScope*` argument around and eliminates HGraph::inexact_object_rti_ and its initialization. The latter shall allow running Optimizing gtests that do not require type information without creating a Runtime in future. (To be implemented in a separate CL.) Test: m test-art-host-gtest Test: testrunner.py --host --optmizing Test: aosp_taimen-userdebug boots. Change-Id: I36fe9bc556c6d610d644c8c14cc74c9985a14d64
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-06-29ART: Fix HSelectGenerator for instructions which can throw. Artem Serov
Make sure that HSelectGenerator doesn't hoist instructions which can throw. Currently this doesn't happen due to SideEffect::CanTriggerGC however this side effect is to be removed for some instructions. Test: select_generator_test. Test: test-art-host, test-art-target. Change-Id: I996f6cbdcee4987a36079d387a7b74b326881ab6
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
2018-04-17Run GVN earlier. Aart Bik
Rationale: Running GVN earlier allows for better subsequent instruction simplifation. For example, running GVN before select generation also finds the MIN in: if (x > a[i]) x = a[i]; Bug: b/74026074 Test: test-art-host,target Change-Id: I633046375637c7809a3603fdf7c5cf77e8f21167
2018-03-30Recognize nested MIN-MAX operations. Aart Bik
Rationale: Prior to this CL, select optimizer and instruction simplifier were unable to deal with more than one select. This CLs improves MIN-MAX recognition by allowing select diamonds to nest deeper and by recognizing constant clipping operations. This yields better optimizable code, as shown with more saturation idioms. Bug: b/74026074 Test: test-art-host,target Change-Id: I8a616a19475f1ae87c2b5210afc76b14265bd571
2017-11-20Refactored optimization passes setup. Aart Bik
Rationale: Refactors the way we set up optimization passes in the compiler into a more centralized approach. The refactoring also found some "holes" in the existing mechanism (missing string lookup in the debugging mechanism, or inablity to set alternative name for optimizations that may repeat). Bug: 64538565 Test: test-art-host test-art-target Change-Id: Ie5e0b70f67ac5acc706db91f64612dff0e561f83
2017-10-12Use ScopedArenaAllocator in BCE, DCE, LSE, ... Vladimir Marko
... ReferenceTypePropagation and GraphChecker. Define and use a new allocation kind for LoadStoreAnalysis. Memory needed to compile the two most expensive methods for aosp_angler-userdebug boot image: BatteryStats.dumpCheckinLocked() : 19.7MiB -> 19.6MiB (-79KiB) BatteryStats.dumpLocked(): 39.4MiB -> 39.3MiB (-120KiB) Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 64312607 Change-Id: Ib0cf074ac21ab67d8f8f2efabbdfb84cce9cae8e
2017-10-06ART: Use ScopedArenaAllocator for pass-local data. Vladimir Marko
Passes using local ArenaAllocator were hiding their memory usage from the allocation counting, making it difficult to track down where memory was used. Using ScopedArenaAllocator reveals the memory usage. This changes the HGraph constructor which requires a lot of changes in tests. Refactor these tests to limit the amount of work needed the next time we change that constructor. Test: m test-art-host-gtest Test: testrunner.py --host Test: Build with kArenaAllocatorCountAllocations = true. Bug: 64312607 Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a
2017-09-25ART: Introduce compiler data type. Vladimir Marko
Replace most uses of the runtime's Primitive in compiler with a new class DataType. This prepares for introducing new types, such as Uint8, that the runtime does not need to know about. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 23964345 Change-Id: Iec2ad82454eec678fffcd8279a9746b90feb9b0c
2017-08-14Merge "RFC: Generate select instruction for conditional returns." Nicolas Geoffray
2017-08-11optimizing: Refactor statistics to use OptimizingCompilerStats helper Igor Murashkin
Remove all copies of 'MaybeRecordStat', replacing them with a single OptimizingCompilerStats::MaybeRecordStat helper. Change-Id: I83b96b41439dccece3eee2e159b18c95336ea933
2017-08-10RFC: Generate select instruction for conditional returns. Mads Ager
The select generator currently only inserts select instructions if there is a diamond shape with a phi. This change extends the select generator to also deal with the pattern: if (condition) { movable instruction 0 return value0 } else { movable instruction 1 return value1 } which it turns into: moveable instruction 0 moveable instruction 1 return select (value0, value1, condition) Test: 592-checker-regression-bool-input Change-Id: Iac50fb181dc2c9b7619f28977298662bc09fc0e1
2016-10-27Remove H[Reverse]PostOrderIterator and HInsertionOrderIterator. Vladimir Marko
Use range-based loops instead, introducing helper functions ReverseRange() for iteration in reverse order in containers. When the contents of the underlying container change inside the loop, use an index-based loop that better exposes the container data modifications, compared to the old iterator interface that's hiding it which may lead to subtle bugs. Test: m test-art-host Change-Id: I2a4e6c508b854c37a697fc4b1e8423a8c92c5ea0
2016-06-07ART: Remove redundant MoveInstructionBefore method David Brazdil
Change-Id: If53d7011197cc6b9c1702a3d98ef11b59eb76f0c
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-01-28ART: Implement HSelect David Brazdil
This patch adds a new HIR instruction to Optimizing. HSelect returns one of two inputs based on the outcome of a condition. This is only initial implementation which: - defines the new instruction, - repurposes BooleanSimplifier to emit it, - extends InstructionSimplifier to statically resolve it, - updates existing code and tests accordingly. Code generators currently emit fallback if/then/else code and will be updated in follow-up CLs to use platform-specific conditional moves when possible. Change-Id: Ib61b17146487ebe6b55350c2b589f0b971dcaaee